Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
1.核心模块:内置的,开箱即用
http
.createServer(function (request, response) {
response.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
response.end("<h2 style='color:red'>今天的天气真好!</h2>");
})
.listen(8081);
console.log("Server running at http://127.0.0.1:8081/");
http
.createServer(function (request, response) {
response.writeHead(200, { "Content-Type": "application/json" });
response.end(`
{
"id":925,
"user":"李同学",
"qq邮箱":"123456789@qq.com"
}
`);
})
.listen(8081);
console.log("Server running at http://127.0.0.1:8081/");
const fs = require("fs");
fs.readFile(__dirname + "/libin.txt", function (err, data) {
if (err) return console.error(err);
console.log(data.toString());
});
2.文件模块:自定义的先声明,在导入
module.exports = {
domain: "WWW.php.cn",
name: "PHP中文网",
getSite() {
return this.name + "(" + this.domain + ")";
},
};
let site = require("./m1.js");
3.第三方模块:npm安装的