-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (28 loc) · 774 Bytes
/
main.go
File metadata and controls
36 lines (28 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"net/http"
)
func homePage(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/home.html")
}
func coursePage(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/courses.html")
}
func aboutPage(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/about.html")
}
func contactPage(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/contact.html")
}
func main() {
log.Println("Starting server on http://0.0.0.0:8080")
http.HandleFunc("/", homePage)
http.HandleFunc("/courses", coursePage)
http.HandleFunc("/about", aboutPage)
http.HandleFunc("/contact", contactPage)
err := http.ListenAndServe("0.0.0.0:8080", nil)
if err != nil {
log.Fatal(err)
}
}