var http=require(‘http’)
//创建Server
var server=http.createServer();
//监听
server.on(‘request’,function(request,response){
// 设置HTTP头部,状态码是 200.文件类型是html,字符集是utf-8
response.writeHead(200, {'Content-Type': 'text/html;charset=utf8'});
var url=request.url
if(url=='/'){
response.end('这是首页')
}else if(url=='/log'){
response.end('这是登录页面')
}
})
server.listen(3000,function(){
console.log(“端口已开启”)
})