commit 09b26b3987e047e4a3aa6718a93de81b21c72c27 Author: fungal Date: Mon Dec 18 11:46:41 2023 +0100 /dev/null diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2786177 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module myceliumlab/emojiquest + +go 1.21.4 diff --git a/main.go b/main.go new file mode 100644 index 0000000..36a9197 --- /dev/null +++ b/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "embed" + "html/template" + "log" + "net/http" +) + +type EmojiDetails struct { + Label string +} + +//go:embed templates +var indexHTML embed.FS + +func main() { + tmpl := template.Must(template.ParseFS(indexHTML, "templates/index.html")) + + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + 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}) + }) + + http.ListenAndServe(":8080", nil) +} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..dadd7d2 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,32 @@ + + + + + + Emoji Request + + + + +
+ {{if .Success}} +

emoji requested successfully

+ {{end}} +

Request An Emoji

+
+ + + + + +
+ +
+ + \ No newline at end of file