Created
June 18, 2014 14:56
-
-
Save socrateslee/14225344464d356d5790 to your computer and use it in GitHub Desktop.
Serving static files in current directory with golang. Simply a "python -m SimpleHTTPServer [PORT]" replacement written in golang. Use it as "static-serve [PORT]"
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 ( | |
"net/http" | |
"os" | |
"fmt") | |
func main() { | |
port := "8080" | |
if len(os.Args) >= 2 { | |
port = os.Args[1] | |
} | |
fmt.Printf("Serving static files on 0.0.0.0:%s ...\n", port) | |
panic(http.ListenAndServe(":" + port, http.FileServer(http.Dir("./")))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment