Last active
September 13, 2017 03:49
-
-
Save alefhsousa/bd13deca253affabb1088d41df9b646e to your computer and use it in GitHub Desktop.
Simple server for share static documents
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" | |
| ) | |
| func main() { | |
| port := flag.String("p", "9999", "port to serve on") | |
| directory := flag.String("d", ".", "the directory of static file to host") | |
| flag.Parse() | |
| http.Handle("/", 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