// Created on savesnippets.com ยท https://savesnippets.com/bO81Zv1BnpKpM9 package main import ( "log" "net/http" ) func main() { mux := http.NewServeMux() // Serve ./public/ at /static/ fs := http.FileServer(http.Dir("./public")) mux.Handle("/static/", http.StripPrefix("/static/", fs)) // Serve a single specific file mux.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "./public/favicon.ico") }) mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) { w.Write([]byte("home page")) }) log.Fatal(http.ListenAndServe(":8080", mux)) }