-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (36 loc) · 1.07 KB
/
main.go
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
37
38
39
40
41
42
43
44
45
package main
import (
"log"
"net/http"
)
func main() {
// File server for static files
fs := http.FileServer(http.Dir("static"))
http.Handle("/", fs)
// Handle dynamic routes if needed in the future
http.HandleFunc("/home", homeHandler)
http.HandleFunc("/project", projectHandler)
http.HandleFunc("/photography", photographyHandler)
http.HandleFunc("/blog", blogHandler)
http.HandleFunc("/about", aboutHandler)
log.Println("Serving on http://localhost:8080")
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
func homeHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/home.html")
}
func projectHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/project.html")
}
func photographyHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/photography.html")
}
func blogHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/blog.html")
}
func aboutHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/about.html")
}