老师请问一下这个问题该怎么解决
const http=require('http')
const querystring = require('querystring')
const server = http.createServer((req, res) => {
var bodyStr = ''
req.on('data', function (chunk) {
bodyStr += chunk
})
req.on('end', function () {
const body = querystring.parse(bodyStr);
// 设置响应头部信息及编码
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
if(body.name && body.age) {
res.write("姓名:" + body.name);
res.write("<br>");
res.write("年龄:" + body.age);
}
res.end()
});
})
server.listen('3030',function(){
console.log('服务器正在监听3030端口')
})
