快速上手
执行:
mkdir demo&&cd demo&&npm init&&npm i simplest-server
接着新建js文件,在里面输入:
const ss = require('simplest-server');
ss.http({
'/': function(req, res){
res.writeHead(200, { 'Content-Type': 'text/html'})
res.end('<h1>Hello World</h1>')
}
}).listen(5000)
使用node运行,访问:http://localhost:5000/ ,你会看到
那么恭喜你,成功了!!
JSON的格式如下:
{
'路径':函数(function类型,否则不会允许)
}