inline style

main
sandyx 1 year ago
parent 45c37c961f
commit 429f57494d

@ -35,7 +35,7 @@ func wrapWithTagHref(str string, tag string) string {
} }
func serveStylesheet(w http.ResponseWriter, r *http.Request) { func serveStylesheet(w http.ResponseWriter, r *http.Request) {
sheet, err := os.Open("style.css") sheet, err := os.Open("styles.css")
if err != nil { if err != nil {
http.Error(w, "File not found", http.StatusNotFound) http.Error(w, "File not found", http.StatusNotFound)
return return
@ -109,7 +109,12 @@ func main() {
contents = wrapWithTagAttrs(contents, "div", gridContainerAttrs) contents = wrapWithTagAttrs(contents, "div", gridContainerAttrs)
contents = wrapWithTag(contents, "pre") contents = wrapWithTag(contents, "pre")
contents = wrapWithTag("<link rel=\"stylesheet\" href=\"style.css\">", "head") + contents style, err := os.ReadFile("styles.css")
if err != nil {
log.Fatal(err)
}
contents = wrapWithTag(string(style), "style") + contents
//contents = wrapWithTag("<link rel=\"stylesheet\" href=\"styles.css\">", "head") + contents
contents = wrapWithTag(contents, "html") contents = wrapWithTag(contents, "html")
contents = "<!DOCTYPE html>" + contents contents = "<!DOCTYPE html>" + contents
@ -118,7 +123,7 @@ func main() {
} }
http.Handle("/", http.HandlerFunc(handler)) http.Handle("/", http.HandlerFunc(handler))
http.Handle("/style.css", http.HandlerFunc(serveStylesheet)) //http.Handle("/styles.css", http.HandlerFunc(serveStylesheet))
log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) log.Printf("Serving %s on HTTP port: %s\n", *directory, *port)
log.Fatal(http.ListenAndServe(":"+*port, nil)) log.Fatal(http.ListenAndServe(":"+*port, nil))
} }

@ -9,7 +9,7 @@
padding: 20px; padding: 20px;
background: green; background: green;
border-radius: 20px; border-radius: 20px;
border: 0px solid white; border: 1px solid white;
text-align: left; text-align: left;
} }
Loading…
Cancel
Save