evilthings/index.go
mStar aka a person 7270bd057e Same as last
2024-01-08 16:58:43 +01:00

23 lines
513 B
Go

package main
import (
"html/template"
"net/http"
"time"
)
type indexData struct {
Time string
}
func handleRoot(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.ParseFS(embed_templates, "templates/index.html")
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)
}
}