www-jmbit-de/server.go

33 lines
687 B
Go
Raw Permalink Normal View History

2024-01-11 09:08:11 +01:00
package main
import (
"log"
"net/http"
"git.jmbit.de/jmb/www-jmbit-de/public"
2024-01-11 09:08:11 +01:00
)
func main() {
// Register a custom handler
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// Specify the file path you want to block
blockFilePath := "/public.go"
// Check if the requested path matches the blocked file path
if r.URL.Path == blockFilePath {
// Return a 404 Not Found error
http.NotFound(w, r)
return
}
// For other paths, serve the files using the file server
http.FileServer(http.FS(public.HtmlFS)).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)
}
}