package main import ( "net/http" "os" "log" "html/template" ) type Index struct { WebpageTitle string } func indexHandler(w http.ResponseWriter, req *http.Request) { tmpl, err := template.ParseFiles("src/index.tmpl") if err != nil { http.Error(w, "Error loading template", http.StatusInternalServerError) log.Println("Error parsing template:", err) return } data := &Index{ WebpageTitle: "Keyemail", } err = tmpl.Execute(w, data) if err != nil { http.Error(w, "Error loading template", http.StatusInternalServerError) log.Println("Error executing template:", err) return } } func main() { if _, err := os.Stat("src/index.tmpl"); os.IsNotExist(err) { log.Fatal("Template file does not exist:\n", err) } port := ":3939" http.HandleFunc("/", indexHandler) log.Println("Server running at http://localhost" + port) http.ListenAndServe(port, nil) }