不到15行---超简单的nodejs的http服务器
2020-09-17 02:34:36

方便大家平时学习使用。

const http = require('http')

http.createServer(function (req, res) {
    let body = ''
    req.on('data', function (data) {
        body += data
    })
    req.on('end', function () {
        console.log(req.method, req.url)
        console.log(body)
        res.end('{"errcode":0}');
    })
}).listen(3000);


文章作者:沃航科技