feat: update Go server to serve static files

This commit is contained in:
2026-08-18 15:19:46 +03:00
parent bd83cca99d
commit b000d7d44f
2 changed files with 15 additions and 3 deletions

View File

@@ -68,6 +68,18 @@ func main() {
}
})
// Serve static files from static/ directory
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
// Serve frontend
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" || r.URL.Path == "/index.html" {
http.ServeFile(w, r, "static/index.html")
return
}
http.NotFound(w, r)
})
log.Println("Trip Planner API starting on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}