Skip to content

Instantly share code, notes, and snippets.

@socrateslee
Created June 18, 2014 14:56
Show Gist options
  • Save socrateslee/14225344464d356d5790 to your computer and use it in GitHub Desktop.
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]"
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