42 lines
856 B
Go
42 lines
856 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"html/template"
|
|
"net/http"
|
|
)
|
|
|
|
type Item struct {
|
|
ID string
|
|
Title string
|
|
}
|
|
|
|
type PageData struct {
|
|
Title string
|
|
// Items []Item
|
|
Selected map[string]bool
|
|
}
|
|
|
|
var tmpl = template.Must(template.ParseGlob("templates/*.html"))
|
|
|
|
func main() {
|
|
|
|
fmt.Println("serving on localhost:8080")
|
|
|
|
http.HandleFunc("/", indexHandler)
|
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
|
http.ListenAndServe(":8080", nil)
|
|
}
|
|
|
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|
selected := map[string]bool{"lords_prayer": false, "collect_for_purity": true}
|
|
data := PageData{
|
|
Title: "The Order for Holy Communion",
|
|
Selected: selected,
|
|
}
|
|
|
|
if err := tmpl.ExecuteTemplate(w, "communion.html", data); err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
}
|
|
}
|