快速上手

Fgaoxing 2022-12-02 18:11:02 2023-01-12 18:33:24

执行:

1
mkdir demo&&cd demo&&npm init&&npm i simplest-server

接着新建js文件,在里面输入:

1
2
3
4
5
6
7
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/ ,你会看到
https://npm.elemecdn.com/ytblogimg/1669985965213.webp
那么恭喜你,成功了!!

JSON的格式如下:

1
2
3
{
'路径':函数(function类型,否则不会允许)
}

上一步
下一步

本站重新进行调试,开始使用自己的主题,过程中,可能会对使用略有影响