let http = require('http');
let url = require('url');
http.createServer((req,res)=>{
//路由:根据不同的路径返回不同的内容
console.log(req.url);
let {pathname,query} = url.parse(req.url,true);
if(pathname === '/index'){//index接口
res.setHeader('Content-Type','text/plain;charset=utf8');
let str = '';
req.on('data',(data) => {
str += data;
});
req.on('end',()=>{
console.log(str)
});
console.log(req.method);
return res.end('登陆');
}
}).listen(3903,()=>{
console.log('开启服务器')
});
node - httpserver
猜你喜欢
转载自blog.csdn.net/memedadexixaofeifei/article/details/86184540
今日推荐
周排行