diff options
author | Emile <hanemile@protonmail.com> | 2019-02-25 23:56:29 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-25 23:56:29 +0100 |
commit | 23ecf18de76e8ef873acac89923232987366c7a9 (patch) | |
tree | eb890f3ab55ebaf84e1f4f494b723985168c4454 /src/main.go | |
parent | de59393dbd2043611de91f0612626bc858256d19 (diff) |
updated the file structure
Diffstat (limited to 'src/main.go')
-rw-r--r-- | src/main.go | 20 |
1 files changed, 18 insertions, 2 deletions
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)) } |