根据用户请求不同路径进行不同的响应
var http = require('http');
http.createServer(function (req, res) {
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
if (req.url === '/' || req.url === '/index') {
res.end('Hello Index');
} else if (req.url === '/login') {
res.end('Hello login');
} else if (req.url === '/list') {
res.end('Hello List');
} else if (req.url === '/register') {
res.end('Hello Register');
} else {
res.end('404, not Found。客户端错误!');
}
}).listen(8080, function () {
console.log('http://localhost:8080');
});