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)
$ npm install quick-local-service -g
$ cd demo
$ qls run
default port: 10086
You can set the port by option -p 8989
.
Also, you can set the dir by option -d demo
.
$ cd demo
$ cd ..
$ qls run -d demo
init
command for generating a config file for options setting named qls.config.js
This is the content of qls.config.js
.
module.exports = {
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
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])
- Interface setting for the ajax request in the page.
- [Done] Proxy the cross-domain interface.
- [Done] Stop running if the port is used already.