www-jmbit-de/server.go

32 lines
490 B
Go
Raw Normal View History

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