evilthings/index.go

24 lines
513 B
Go
Raw Normal View History

2023-09-18 09:15:19 +00:00
package main
import (
"html/template"
"net/http"
"time"
)
type indexData struct {
Time string
}
func handleRoot(w http.ResponseWriter, r *http.Request) {
2024-01-08 15:58:43 +00:00
tmpl, err := template.ParseFS(embed_templates, "templates/index.html")
2023-09-18 09:15:19 +00:00
if err != nil {
http.Error(w, "Couldn't parse template file", http.StatusInternalServerError)
return
}
err = tmpl.Execute(w, indexData{Time: time.Now().Format(time.Stamp)})
if err != nil {
http.Error(w, "Failed to execute template", http.StatusInternalServerError)
}
}