From 23ecf18de76e8ef873acac89923232987366c7a9 Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 25 Feb 2019 23:56:29 +0100 Subject: updated the file structure --- src/main.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/main.go') diff --git a/src/main.go b/src/main.go index 0808608..ce4bb9f 100644 --- a/src/main.go +++ b/src/main.go @@ -1,7 +1,23 @@ package main -import "net/http" +import ( + "net/http" +) + func main() { - panic(http.ListenAndServe(":80", http.FileServer(http.Dir("./")))) + + // serve the index page + http.Handle("/", http.FileServer(http.Dir("./static"))) + + // serve the contact page + http.HandleFunc("/contact/", func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, "static/contact.html") + }) + + // server the static css + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) + + // start listening to incomming connections and serve the appropriate files + panic(http.ListenAndServe(":80", nil)) } -- cgit 1.4.1