Add contact page template

This commit is contained in:
Lucas Schumacher 2024-07-31 20:59:17 -04:00
parent 393cc1f3c0
commit eb6d144e92
2 changed files with 18 additions and 1 deletions

13
main.go
View File

@ -26,7 +26,18 @@ func homeHandler(w http.ResponseWriter, r *http.Request) {
} }
func contactHandler(w http.ResponseWriter, r *http.Request) { func contactHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf8") w.Header().Set("Content-Type", "text/html; charset=utf8")
fmt.Fprint(w, "<h1>Contact Page</h1><p>To get in touch, email me at <a href=\"mailto:example@example.com\">example@example.com</a></p>") tpl, err := template.ParseFiles("templates/contact.gohtml")
if err != nil {
log.Printf("Error parsing template: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
err = tpl.Execute(w, nil)
if err != nil {
log.Printf("Error executing template: %v", err)
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
} }
func faqHandler(w http.ResponseWriter, r *http.Request) { func faqHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf8") w.Header().Set("Content-Type", "text/html; charset=utf8")

6
templates/contact.gohtml Normal file
View File

@ -0,0 +1,6 @@
<h1>FAQ</h1>
<hr>
<h3>Is this a real website?</h3>
<p>No.</p>
<h3>I Can Has Cheezburger?</h3>
<p>No.</p>