Add index page and link to share more easily

This commit is contained in:
2025-01-20 10:13:59 +01:00
parent 5668b1cd6a
commit bddae031cc
5 changed files with 53 additions and 6 deletions

View File

@ -17,6 +17,17 @@ import (
"time"
)
func (app *application) indexPage(w http.ResponseWriter, r *http.Request) {
content, err := ui.Files.ReadFile("index.html")
if err != nil {
app.serverError(w, r, err)
return
}
w.Header().Set("Content-Type", "text/html")
w.Write(content)
}
func (app *application) createElectionPage(w http.ResponseWriter, r *http.Request) {
content, err := ui.Files.ReadFile("create-election.html")
if err != nil {

View File

@ -22,6 +22,7 @@ func (app *application) routes() http.Handler {
cached := alice.New(app.cacheStatic)
mux.Handle("GET /static/", cached.Then(http.FileServerFS(ui.Files)))
mux.HandleFunc("GET /", app.indexPage)
mux.HandleFunc("GET /election/create", app.createElectionPage)
mux.HandleFunc("GET /election/{id}", app.getElectionPage)