From 19af2a1cc8825dd9b89cd83b92c7ff9df9b6effb Mon Sep 17 00:00:00 2001 From: sandyx Date: Tue, 19 Nov 2024 11:24:40 -0600 Subject: [PATCH] fix stylesheet --- main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 659d2b4..bb20aad 100644 --- a/main.go +++ b/main.go @@ -66,15 +66,12 @@ func main() { for _, e := range entries { new := e.Name() + + if new == "style.css" { continue } + http.HandleFunc("/" + url.QueryEscape(new), func(w http.ResponseWriter, r *http.Request) { log.Println("Request for resource: ", r.RequestURI) - //could also generate the css at runtime - if r.RequestURI == "/style.css" { - serveStylesheet(w, r) - return - } - file, err := os.Open(*directory + "/" + new) if err != nil { http.Error(w, "File not found.", http.StatusNotFound) @@ -121,6 +118,7 @@ func main() { } http.Handle("/", http.HandlerFunc(handler)) + http.Handle("/style.css", http.HandlerFunc(serveStylesheet)) log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) log.Fatal(http.ListenAndServe(":"+*port, nil)) }