diff --git a/handlers/mainPage.go b/handlers/mainPage.go index f23de7b..a5ec2fb 100644 --- a/handlers/mainPage.go +++ b/handlers/mainPage.go @@ -34,18 +34,18 @@ func NewMainPage(templates *embed.FS) (*MainPage, error) { } func (m *MainPage) UpdateMainPage(w http.ResponseWriter, r *http.Request) { - // tmpl := template.Must( - // template.New("index.html").ParseFS( - // m.templates, - // "templates/index.html", - // ), - // ) - tmpl := template.Must( - template.New("index.html").ParseFiles( + template.New("index.html").ParseFS( + m.templates, "templates/index.html", ), ) + + // tmpl := template.Must( + // template.New("index.html").ParseFiles( + // "templates/index.html", + // ), + // ) tmpl.Execute(w, m) } diff --git a/main.go b/main.go index e20778c..bfeb514 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "embed" "flag" "fmt" + "io/fs" "log" "net/http" "processSupervisor/handlers" @@ -28,7 +29,12 @@ func main() { panic(err) } - http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS)))) + staticSub, err := fs.Sub(staticFS, "static") + if err != nil { + log.Fatal(err) + } + + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub)))) http.HandleFunc("/taskmanager/htop", htop.UpdateHTop) http.HandleFunc("/", mainPage.UpdateMainPage) diff --git a/templates/index.html b/templates/index.html index 39bf78a..f28cade 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,7 +8,10 @@ -