move template in bin

This commit is contained in:
Adrian Zürcher
2025-08-05 17:17:02 +02:00
parent 0e8864d4da
commit dd5ebb60fd
3 changed files with 62 additions and 16 deletions

25
main.go
View File

@@ -1,6 +1,7 @@
package main
import (
"embed"
"flag"
"fmt"
"log"
@@ -8,24 +9,32 @@ import (
"processSupervisor/handlers"
)
//go:embed templates/*.html templates/*/*.html
var templatesFS embed.FS
//go:embed static
var staticFS embed.FS
func main() {
port := flag.Uint("port", 9400, "listenig port")
flag.Parse()
htop, err := handlers.NewHTopHandler()
port := flag.Uint("port", 9400, "listening port")
htop, err := handlers.NewHTopHandler(&templatesFS)
if err != nil {
panic(err)
}
fs := http.FileServer(http.Dir("static"))
http.Handle("/static/", http.StripPrefix("/static/", fs))
mianPage, err := handlers.NewMainPage(&templatesFS)
if err != nil {
panic(err)
}
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS))))
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
http.HandleFunc("/", handlers.UpdateMainPage)
http.HandleFunc("/", mianPage.UpdateMainPage)
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
log.Printf("Listening on http://localhost:%d/taskmanager/htop\n", *port)
log.Printf("Listening on http://localhost:%d\n", *port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
}