Skip to content

Instantly share code, notes, and snippets.

@anastasop
Created January 16, 2015 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anastasop/f3534a3c4826286d0d58 to your computer and use it in GitHub Desktop.
Save anastasop/f3534a3c4826286d0d58 to your computer and use it in GitHub Desktop.
A web server for a single directory with content sniffing
import (
"flag"
"log"
"net/http"
)
var addr = flag.String("-h", ":8080", "host:port")
var dir = flag.String("-d", ".", "directory to serve")
func main() {
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*dir)))
log.Fatal(http.ListenAndServe(*addr, nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment