【发布时间】:2021-01-06 06:29:45
【问题描述】:
这里的 {'Content-Type': 'text/html'} 有什么用?
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
fs.readFile('demofile.html', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
res.end();
});
}).listen(8080);
console.log("Listening at 8080...");`
【问题讨论】:
-
请在提出问题之前尝试至少做一个非常少的研究(只需在 Google 搜索框中输入“什么是内容类型标题?”问题并按 Enter 键)。这将帮助您在未来提出更好的问题。
标签: javascript html node.js filesystems