Add contact page
This commit is contained in:
parent
7816f43ca7
commit
428263c34e
9
main.go
9
main.go
@ -5,13 +5,18 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handlerFunc(w http.ResponseWriter, r *http.Request) {
|
||||
func homeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf8")
|
||||
fmt.Fprint(w, "<h1>Welcome to my awesome site!</h1>")
|
||||
}
|
||||
func contactHandler(w http.ResponseWriter, r *http.Request) {
|
||||
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>")
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handlerFunc)
|
||||
http.HandleFunc("/", homeHandler)
|
||||
http.HandleFunc("/contact", contactHandler)
|
||||
fmt.Println("Starting the server on :3000...")
|
||||
http.ListenAndServe(":3000", nil)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user