多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` let http = require('http'); let server = http.createServer(function(req,res){ console.log('ok'); let contentType = req.headers['content-type']; let buffers = []; req.on('data',function(chunk){ buffers.push(chunk); }) req.on('end',function(){ // console.log(JSON.parse(Buffer.concat(buffers).toString()).name); let content = Buffer.concat(buffers).toString(); if(contentType === 'application/json'){ console.log(JSON.parse(content).name); }else if(contentType === 'application/x-www-form-urlencoded'){ let queryString = require('querystring'); console.log(queryString.parse(content).name); } }) res.end(); }); server.listen(4000); ```