通过req.url拿到用户请求的路径进行判断
console.log(req.url)
在cmd上输出 并不是在浏览器的控制台上
/favicon.ico自动请求的浏览器图标
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') // 相当于res.write('hello index')
// res.end()
}else if(req.url==='/login' ){
res.end(' login')
}else if(req.url==='/list'){
res.end(' list')
}else {
res.end('404 not Found')
}
}).listen(8080,function () {
console.log('服务器启动了 请访问: http://localhost:8080')
})