const http = require('http');
const fs = require('fs');
const server = http.createServer((req, res) => {
switch(req.url){
case '/1.html':
fs.readFile('text.txt', (err, data)=>{
res.write(data.toString());
res.end()
})
break;
case '/2.html':
fs.writeFile('text2.txt', '我是是是是是是是是是', err =>{
console.log(err)
})
break;
}
})
server.listen(8080)
网友评论