Add README
This commit is contained in:
parent
66f13d9a83
commit
e27714e4cb
|
@ -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
|
||||
```
|
3
main.go
3
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)
|
||||
|
|
Loading…
Reference in New Issue