我想读取一个文件并返回作为对GET
请求的响应
这就是我正在做的
app.get('/', function (request, response) {
fs.readFileSync('./index.html', 'utf8', function (err, data) {
if (err) {
return 'some issue on reading file';
}
var buffer = new Buffer(data, 'utf8');
console.log(buffer.toString());
response.send(buffer.toString());
});
});
index.html
是
hello world!
当我加载页面localhost:5000
时,页面旋转并且没有任何反应,我在这里做错了什么
我是 Node.js 的新手。