Added basic admin page

This commit is contained in:
2025-08-24 01:30:12 +02:00
parent 70960057c1
commit 4d81678c1d
12 changed files with 262 additions and 36 deletions
+17 -1
View File
@@ -1,6 +1,7 @@
package main
import (
"Advertisement_Panel/src"
"fmt"
"html/template"
"net/http"
@@ -23,11 +24,12 @@ func main() {
templ, _ = template.ParseGlob("templates/*.html")
fmt.Print("Now running server!\n")
// Serves index
http.HandleFunc("/", index_handler)
// Serves json for html to find file names
http.HandleFunc("/files", file_handler)
http.HandleFunc("/files", src.FileHandler)
// Serves ascii page
http.HandleFunc("/ascii", ascii_handler)
@@ -35,8 +37,19 @@ func main() {
// Serves images
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
http.Handle("/uploads/", http.StripPrefix("/uploads/", http.FileServer(http.Dir("./uploads"))))
// Serves administration page
http.HandleFunc("/admin/", admin_handler)
// Handles image upload
http.HandleFunc("/upload", src.UploadHandler)
fmt.Print("Webserver running on http://localhost:8080\n")
// Serves what ever the user is requesting base on above urls
http.ListenAndServe(":8080", nil)
}
func index_handler(w http.ResponseWriter, r *http.Request) {
@@ -46,3 +59,6 @@ func index_handler(w http.ResponseWriter, r *http.Request) {
func ascii_handler(w http.ResponseWriter, r *http.Request) {
templ.ExecuteTemplate(w, "ascii.html", nil)
}
func admin_handler(w http.ResponseWriter, r *http.Request) {
templ.ExecuteTemplate(w, "admin.html", nil)
}