-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb56872
commit a253679
Showing
6 changed files
with
99 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func fetchYouTubeMetricsFromAPI(c *gin.Context) { | ||
resp, err := http.Get("https://mattmajestic.dev/youtube-metrics") | ||
if err != nil { | ||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch YouTube metrics"}) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
|
||
c.DataFromReader(http.StatusOK, resp.ContentLength, resp.Header.Get("Content-Type"), resp.Body, nil) | ||
resp, err := http.Get("https://mattmajestic.dev/youtube-metrics") | ||
if err != nil { | ||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch YouTube metrics"}) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
c.DataFromReader(http.StatusOK, resp.ContentLength, resp.Header.Get("Content-Type"), resp.Body, nil) | ||
} | ||
|
||
func main() { | ||
router := gin.Default() | ||
|
||
router.LoadHTMLGlob("templates/*") | ||
|
||
router.GET("/", func(c *gin.Context) { | ||
c.HTML(http.StatusOK, "index.tmpl", nil) | ||
}) | ||
|
||
router.GET("/youtube-metrics", fetchYouTubeMetricsFromAPI) | ||
|
||
router.Run(":8080") | ||
// Initialize Gin router | ||
router := gin.Default() | ||
|
||
// Serve static files | ||
router.GET("/styles.css", func(c *gin.Context) { | ||
c.File("./static/styles.css") | ||
}) | ||
router.GET("/script.js", func(c *gin.Context) { | ||
c.File("./static/script.js") | ||
}) | ||
|
||
// Load HTML templates | ||
router.LoadHTMLGlob("templates/*") | ||
|
||
// Define routes | ||
router.GET("/", func(c *gin.Context) { | ||
// Render the index template | ||
c.HTML(http.StatusOK, "index.tmpl", nil) | ||
}) | ||
|
||
// Route to fetch YouTube metrics from API | ||
router.GET("/youtube-metrics", fetchYouTubeMetricsFromAPI) | ||
|
||
// Run the server on port 8080 | ||
router.Run(":8080") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const body = document.body; | ||
|
||
// Function to toggle between light and dark themes | ||
function toggleTheme() { | ||
if (body.classList.contains("dark")) { | ||
// Switch to light theme | ||
body.classList.remove("dark"); | ||
} else { | ||
// Switch to dark theme | ||
body.classList.add("dark"); | ||
} | ||
} | ||
|
||
// Add click event listener to the theme toggle button | ||
const themeToggle = document.getElementById("theme-toggle"); | ||
themeToggle.addEventListener("click", toggleTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.custom-button { | ||
background-color: #1C3D63; | ||
color: #fff; | ||
border: none; | ||
padding: 10px 20px; | ||
border-radius: 5px; | ||
text-decoration: none; | ||
transition: background-color 0.3s ease; | ||
margin-bottom: 10px; | ||
cursor: pointer; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.custom-button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.theme-toggle-icon { | ||
font-size: 24px; | ||
} | ||
|
||
/* Dark Theme */ | ||
body.dark { | ||
background-color: #fff; | ||
color: #1C3D63; | ||
} | ||
|
||
footer { | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
background-color: #333; | ||
color: #fff; | ||
text-align: center; | ||
padding: 8px 0; | ||
} | ||
|
||
.custom-button i { | ||
margin-right: 5px; /* Adjust the margin as needed for spacing */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.