From eb6d144e92298f9380264cd0d31f35fda0135e95 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Wed, 31 Jul 2024 20:59:17 -0400 Subject: [PATCH] Add contact page template --- main.go | 13 ++++++++++++- templates/contact.gohtml | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 templates/contact.gohtml diff --git a/main.go b/main.go index 37b47f8..12cb4e6 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,18 @@ func homeHandler(w http.ResponseWriter, r *http.Request) { } func contactHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf8") - fmt.Fprint(w, "

Contact Page

To get in touch, email me at example@example.com

") + 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) { w.Header().Set("Content-Type", "text/html; charset=utf8") diff --git a/templates/contact.gohtml b/templates/contact.gohtml new file mode 100644 index 0000000..1919ba3 --- /dev/null +++ b/templates/contact.gohtml @@ -0,0 +1,6 @@ +

FAQ

+
+

Is this a real website?

+

No.

+

I Can Has Cheezburger?

+

No.