单页应用服务器
项目描述
单页应用的开发服务器。
当python -m http.server不足时。
功能
服务单页应用,即无论请求的路径如何都提供相同的HTML页面。
同时服务静态文件
如果缺少静态文件,则返回“正常”的404错误,以避免在例如期望脚本时返回HTML。
支持SSL。这在您想要在本地使用自定义域名测试浏览器地理位置API等时非常有用(浏览器只允许在HTTPS或localhost上进行地理位置)。
示例用法
这将很好地为演示应用程序提供服务
spas --bind 127.0.0.1 --port 8000 --root ./demo-app/ --static js,css,img --default-page index.html
请注意,由于大多数选项都有可接受的默认值,以下命令也可以做到相同的事情
spas --root ./demo-app/
完整命令帮助
usage: spas [-h] [--bind ADDRESS] [--port PORT] [--root ROOT] [--static LIST] [--default-page PATH] [--ssl] optional arguments: -h, --help show this help message and exit --bind ADDRESS, -b ADDRESS Specify alternate bind address [default: all interfaces] --port PORT, -p PORT Specify alternate port [default: 8000] --root ROOT Root directory to serve. --static LIST Comma-separated list of folders containing static files. File not found inside one of these folders will return 404 instead of the default index page. --default-page PATH Path to the default HTML page to be served for non- existing paths. Default: index.html. Relative to the root path. --ssl Enable SSL