const http = require('http');
const url = require('url');
const server = http.createServer((req, res)=> {
let pn = url.parse(req.url,true).pathname;
res.writeHead(200, {'Content-Type': 'text/plain'});
if('/'==pn) {
res.end('index\n');
} else if('/abc'==pn) {
res.end('abc\n');
} else {
res.end('404\n');
}
});
server.listen(8888);
console.log('请访问http://127.0.0.1:8888/');