node.js http模块和fs模块上机实验·

时间:2022-04-05 04:32:33
  • httpserver
const httpserver = require('http');
var server = httpserver.createServer(function (req,res) {
console.log(req.url);
res.write("there is a game of love");
res.end();
});
server.listen();
  • fs模块
const myfs = require('fs');
//myfs.readAsText('E:\\新建文件夹\\月关\\步步生莲\\317464.html');
myfs.readFile('E:\\新建文件夹\\月关\\步步生莲\\317464.html','utf-8',(err,data)=>{
console.log(data);
});