-
-
Save podanypepa/b018b71c6c6503e69b0ac21f670ead78 to your computer and use it in GitHub Desktop.
This file contains 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" | |
"fmt" | |
"net/http" | |
) | |
const ( | |
defaultPort = 9999 | |
defaultDir = "." | |
) | |
func main() { | |
port := flag.Int("port", defaultPort, "server port") | |
dir := flag.String("dir", defaultDir, "served dir") | |
flag.Parse() | |
handler := http.FileServer(http.Dir(*dir)) | |
fmt.Println("served dir:", *dir) | |
fmt.Printf("start http static server on http://127.0.0.1:%d\n", *port) | |
http.ListenAndServe(fmt.Sprintf(":%d", *port), handler) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment