Add page for results

This commit is contained in:
2025-01-20 18:08:19 +01:00
parent 37b06cfb9e
commit 1b6fc173d3
3 changed files with 157 additions and 0 deletions

View File

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

View File

@ -24,6 +24,7 @@ func (app *application) routes() http.Handler {
mux.HandleFunc("GET /", app.indexPage)
mux.HandleFunc("GET /election/create", app.createElectionPage)
mux.HandleFunc("GET /election/{id}/results", app.getElectionResultsPage)
mux.HandleFunc("GET /election/{id}", app.getElectionPage)
api.HandlerWithOptions(app, api.StdHTTPServerOptions{