Add contact page template
This commit is contained in:
parent
393cc1f3c0
commit
eb6d144e92
13
main.go
13
main.go
@ -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
6
templates/contact.gohtml
Normal 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>
|
||||||
Loading…
x
Reference in New Issue
Block a user