Add README

This commit is contained in:
amutake 2014-12-30 05:48:44 +09:00
parent 66f13d9a83
commit e27714e4cb
2 changed files with 28 additions and 2 deletions

27
README.md Normal file
View File

@ -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
```

View File

@ -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)