Files
2024-01-16 15:01:04 +08:00

20 lines
544 B
JavaScript

const http=require('http')
const server=http.createServer()
server.on('request',function(req,res){
const url=req.url;
let content = '<h1>404 Not found!</h1>'
if(url=='/' || url=='index'){
content = '<h1>首页</h1>'
}
else if(url=='hehe'){
content = '<h1>关于页面</h1>'
}
else{
content = 'xxxxxxxxxxxxxxxx'
}
res.setHeader('Content-Type','text/html;charset=utf-8')
res.end(content);
})
server.listen(9999, () =>{
console.log('http server running at http://127.0.0.1:9999')
})