package main import ( "embed" "html/template" "log" "net/http" ) type EmojiDetails struct { Label string } //go:embed templates var indexHTML embed.FS func handleForm(w http.ResponseWriter, r *http.Request) { tmpl := template.Must(template.ParseFS(indexHTML, "templates/index.html")) if r.Method != http.MethodPost { tmpl.Execute(w, nil) return } details := EmojiDetails{ Label: r.FormValue("label"), } log.Print(details.Label) tmpl.Execute(w, struct{ Success bool }{true}) } func setupRoutes() { http.HandleFunc("/", handleForm) http.ListenAndServe(":8080", nil) } func main() { setupRoutes() }