Pratyush Desai
d3193b92dc
Set the base routing and base html Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
40 lines
971 B
Go
40 lines
971 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
|
|
|
// Define routes
|
|
http.HandleFunc("/", homeHandler)
|
|
http.HandleFunc("/hl2", hl2Handler)
|
|
http.HandleFunc("/quake", quakeHandler)
|
|
|
|
// Start the server
|
|
fmt.Println("Server running on http://localhost:8080")
|
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
}
|
|
|
|
// Render the homepage
|
|
func homeHandler(w http.ResponseWriter, r *http.Request) {
|
|
tmpl := template.Must(template.ParseFiles("templates/index.xhtml"))
|
|
tmpl.Execute(w, nil)
|
|
}
|
|
|
|
// Render the Half-Life 2 page
|
|
func hl2Handler(w http.ResponseWriter, r *http.Request) {
|
|
tmpl := template.Must(template.ParseFiles("templates/hl2.xhtml"))
|
|
tmpl.Execute(w, nil)
|
|
}
|
|
|
|
// Render the Quake page
|
|
func quakeHandler(w http.ResponseWriter, r *http.Request) {
|
|
tmpl := template.Must(template.ParseFiles("templates/quake.xhtml"))
|
|
tmpl.Execute(w, nil)
|
|
}
|