quick-local-service
cli for static web page quick-start
When you programed a page name index.html\other.html, you can use quick-local-service to start web service to host the page, so you can get the page in the browser like http://127.0.0.1:10086/index.html (index.html is the default page)
how to use
install
$ npm install quick-local-service -g
Arrive the page directory and run the service
$ cd demo$ qls run
default port: 10086
You can set the port by option -p 8989
.
Also, you can set the dir by potion -d demo
.
$ cd demo$ cd ..$ qls run -d demo
config file
init
command for generating a config file for options setting named qls.config.js
This is the content of qls.config.js
.
moduleexports = port:10086 dir:"" proxy:{}
init
sets the current path for the option dir
.
Also, you can tell qls
to use another custom config file by option '-c other.config.js'
$ qls run -c other.config.js
config file for proxy cross-domain interface
in qls.config.js
module.exports = {
port: 10086,
dir: '',
proxy:{
'/api':{
host:'http://127.0.0.1:8910',
pathRewrite:{
'^/api': '/api'
}
}
}
}
You can see the example directory. (html/proxy.html [qls run], service/other-proxy.js [node other-proxy.js])
Todo:
- Interface setting for the ajax request in the page.
- [Done] Proxy the cross-domain interface.
- [Done] Stop running if the port is used already.