index — crispy-website @ 4b5cb38fc5c457cead5165bbcbd88e93f3eb85d9

My personal homepage (very crispy)

just a little testing
crispy-caesus 114518720+crispy-caesus@users.noreply.github.com
Fri, 01 Nov 2024 13:11:12 +0100
commit

4b5cb38fc5c457cead5165bbcbd88e93f3eb85d9

parent

7338fdf7d16abdd20dc52963c3db069a969e6f36

1 files changed, 13 insertions(+), 15 deletions(-)

jump to
M index.goindex.go

@@ -1,33 +1,31 @@

package main import ( - "log" - "net/http" - "html/template" + "html/template" + "log" + "net/http" ) type Page struct { - Title string - Body []byte + Title string + Body []byte } var templates = template.Must(template.ParseFiles("index.html")) func renderTemplate(w http.ResponseWriter, tmpl string, p *Page) { - err := templates.ExecuteTemplate(w, tmpl+".html", p) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } + err := templates.ExecuteTemplate(w, tmpl+".html", p) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } } func viewHandler(w http.ResponseWriter, r *http.Request) { - p := &Page{Title: "index"} - renderTemplate(w, "index", p) + p := &Page{Title: "index"} + renderTemplate(w, "index", p) } - func main() { - http.HandleFunc("/", viewHandler) - log.Fatal(http.ListenAndServe(":8080", nil)) + http.HandleFunc("/", viewHandler) + log.Fatal(http.ListenAndServe(":8080", nil)) } -