Last active
June 16, 2022 10:48
-
-
Save hauxe/09cd680deb9c8c4e36d61568db57647b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"log" | |
"net/http" | |
"strings" | |
) | |
func main() { | |
port := flag.String("p", "3000", "port to serve on") | |
directory := flag.String("d", ".", "the directory of static file to host") | |
flag.Parse() | |
http.Handle("/statics/", http.StripPrefix(strings.TrimRight("/statics/", "/"), http.FileServer(http.Dir(*directory)))) | |
log.Printf("Serving %s on HTTP port: %s\n", *directory, *port) | |
log.Fatal(http.ListenAndServe(":"+*port, nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment