Simple static file server for single-page application
Go to file
Reinaldy Rafli 2323cf3f89
fix: provide content type for any other result
2023-05-05 22:29:56 +07:00
.idea faet: more configurable options 2023-04-18 08:16:09 +07:00
README.md faet: more configurable options 2023-04-18 08:16:09 +07:00
go.mod faet: more configurable options 2023-04-18 08:16:09 +07:00
go.sum faet: more configurable options 2023-04-18 08:16:09 +07:00
main.go fix: provide content type for any other result 2023-05-05 22:29:56 +07:00

README.md

spa-server

Simple static file server for single-page application

This fork introduces a bunch of configuration and code cleanup. You can specify a custom listening hostname and port, as well as custom base directory for the files. It is as simple as:

PORT=3000 HOST=127.0.0.1 BASE_DIRECTORY=/home/ubuntu/application spa-server

Please build the binary yourself.

# Assuming you already have Go
go build .
./spa-server
$ 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