diff --git a/main.go b/main.go index df3b7a1..3c276d2 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "html/template" "net/http" "github.com/go-chi/chi/v5" @@ -9,7 +10,14 @@ import ( func homeHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf8") - fmt.Fprint(w, "

Welcome to my awesome site!

") + tpl, err := template.ParseFiles("templates/home.gohtml") + if err != nil { + panic(err) + } + err = tpl.Execute(w, nil) + if err != nil { + panic(err) + } } func contactHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf8") diff --git a/templates/home.gohtml b/templates/home.gohtml new file mode 100644 index 0000000..771ec11 --- /dev/null +++ b/templates/home.gohtml @@ -0,0 +1 @@ +

Welcome to my awesome site!