Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created April 24, 2014 15:54
Show Gist options
  • Save NanoDano/11259688 to your computer and use it in GitHub Desktop.
Save NanoDano/11259688 to your computer and use it in GitHub Desktop.
package main
import (
"net/http"
"fmt"
"flag"
)
func main() {
// check args and set defaults
dir := flag.String("r", "./", "Root for HTTP File Server")
port := flag.Int("p", 8000, "Listen port")
flag.Parse()
// Echo to user settings
fmt.Printf("---\nListening on port %d.\nServing from %s\n---", *port, *dir)
// Set up HTTP file server
http.Handle("/", http.FileServer(http.Dir(*dir)))
http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment