move template in bin
This commit is contained in:
25
main.go
25
main.go
@@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user