Start a web server, and mock data. Inspired by Express.
npm install -g server-mock
server start
# or
mock start
# or
server open
- create a router.js file in current folder
- edit router.js file
app.get('/hello', function(req, res) {
res.send({
status: 0,
msg: "hello hunger valley"
})
});
- in your index.html
$.get('/hello').done(function(ret){
console.log(ret);
});
You can run server init
to create example files such as router.js and index.html, and run server start
to test your server.
Your can refer to http://expressjs.com/en/guide/routing.html to see more usage of router.
More usage
server start --port 3000
server start --public public
server start --views views
server start --tpl ejs
server start --tpl ejs --port 3003