Created
April 24, 2014 15:54
-
-
Save NanoDano/11259688 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 ( | |
"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