mirror of
https://codeberg.org/mycelium/emojiquest.git
synced 2024-09-29 14:57:54 +00:00
/dev/null
This commit is contained in:
commit
09b26b3987
36
main.go
Normal file
36
main.go
Normal file
|
@ -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)
|
||||
}
|
32
templates/index.html
Normal file
32
templates/index.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Emoji Request</title>
|
||||
<style>
|
||||
main {
|
||||
max-width: 70ch;
|
||||
padding: 2rem;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
{{if .Success}}
|
||||
<h1>emoji requested successfully</h1>
|
||||
{{end}}
|
||||
<h1>Request An Emoji</h1>
|
||||
<form method="POST">
|
||||
<span>
|
||||
<label for="emojiLabel">Emoji label</label>
|
||||
<input type="text" id="emojiLabel" name="label" placeholder="blobcatNotLikeThis">
|
||||
</span>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</main>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue