Last active
October 10, 2017 11:09
-
-
Save nl5887/8aaee404c6bef30d23eb to your computer and use it in GitHub Desktop.
Extreme simple (golang) webserver to serve static files. Easy for testing.
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" | |
) | |
func main() { | |
path := flag.String("path", ".", "path to static files") | |
port := flag.String("port", "8080", "port number, default: 8080") | |
flag.Parse() | |
fmt.Printf("Super simple static server started.\nListening on 127.0.0.1:%s, serving path \"%s\".\n", *port, *path) | |
fmt.Printf("---------------------------\n") | |
panic(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%s", *port), http.FileServer(http.Dir(*path)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment