diff --git a/README.md b/README.md new file mode 100644 index 0000000..403f7ca --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +spa-server +========== + +Simple static file server for single-page application + +```sh +$ tree +. +|-- index.html +`-- assets + |-- js + | `-- main.js + `-- css + `-- main.css +$ sap-server 5050 +... +$ curl http://localhost:5050/ +=> ./index.html +$ curl http://localhost:5050/assets/js/main.js +=> ./assets/js/main.js +$ curl http://localhost:5050/index.html +=> ./index.html +$ curl http://localhost:5050/page1 +=> ./index.html +$ curl http://localhost:5050/page2/123 +=> ./index.html +``` diff --git a/main.go b/main.go index c12dfee..aad3f1b 100644 --- a/main.go +++ b/main.go @@ -32,14 +32,13 @@ func handler(w http.ResponseWriter, r *http.Request) { func main() { port := ":5050" - flag.Parse() if flag.NArg() != 0 { port = ":" + flag.Arg(0) } + fmt.Println("spa-server starting on localhost" + port) http.HandleFunc("/", handler) - fmt.Println("spa-server starting on localhost" + port) err := http.ListenAndServe(port, nil) if err != nil { log.Fatal("spa-server: ", err)