Reset project

This commit is contained in:
2025-05-25 10:14:48 +02:00
parent 542d28e7a9
commit 6e443de84f
197 changed files with 64591 additions and 1027 deletions

View File

@@ -14,19 +14,26 @@ type PageData struct {
func RootHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
file, err := web.Templates.ReadFile("templates/index.html")
if err != nil {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
slog.Error("Error reading template", "error", err)
return
}
slog.Info("Render root handler")
tpl := template.Must(template.ParseFS(web.Templates, "templates/index.html", "templates/base.html"))
tmpl := template.Must(template.New("index.html").Parse(string(file)))
// basefile, err := web.Templates.ReadFile("templates/base.html")
// if err != nil {
// http.Error(w, "Internal Server Error", http.StatusInternalServerError)
// slog.Error("Error reading template", "error", err)
// return
// }
// file, err := web.Templates.ReadFile("templates/index.html")
// if err != nil {
// http.Error(w, "Internal Server Error", http.StatusInternalServerError)
// slog.Error("Error reading template", "error", err)
// return
// }
data := PageData{
Title: "Home",
Title: "DyeForYarn",
}
if err := tmpl.Execute(w, data); err != nil {
if err := tpl.ExecuteTemplate(w, "base", data); err != nil {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
slog.Error("Error executing template", "error", err)
}