diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 928ea06..a064606 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -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 { diff --git a/cmd/web/routes.go b/cmd/web/routes.go index b303c93..99a42c9 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -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) diff --git a/ui/create-election.html b/ui/create-election.html index 76bd409..95d4182 100644 --- a/ui/create-election.html +++ b/ui/create-election.html @@ -3,7 +3,7 @@
-Start your journey by creating a new election.
+