2024-01-11 09:08:11 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-11-26 09:09:05 +01:00
|
|
|
"embed"
|
|
|
|
"io/fs"
|
2024-01-11 09:08:11 +01:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-11-26 09:09:05 +01:00
|
|
|
//go:embed public/*
|
|
|
|
var publicFS embed.FS
|
|
|
|
|
|
|
|
|
2024-01-11 09:08:11 +01:00
|
|
|
func main() {
|
2024-01-11 14:42:33 +01:00
|
|
|
// Register a custom handler
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
2024-11-26 09:09:05 +01:00
|
|
|
fsroot, err := fs.Sub(publicFS, "public")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
http.FileServer(http.FS(fsroot)).ServeHTTP(w,r)
|
2024-01-11 14:42:33 +01:00
|
|
|
|
|
|
|
})
|
2024-01-11 09:08:11 +01:00
|
|
|
|
2024-01-11 14:42:33 +01:00
|
|
|
// Start the HTTP server on port 80
|
2024-11-26 09:09:05 +01:00
|
|
|
err := http.ListenAndServe(":1313", nil)
|
2024-01-11 09:08:11 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|