Express Guide hello.txt不起作用



我在这里使用快速指南http://expressjs.com/guide.html#intro.不过,我收到了一个无法获取/错误。有人帮忙吗?

var express = require('express');
var app = express();
app.get('/hello.txt', function(req, res){
  res.send('Hello World');
});
app.listen(10397);
console.log('Listening on port 10397');

如果在浏览器中打开http://localhost:10397/hello.txt,它就会工作。如果您只想加载站点的根目录:http://localhost:10397,则需要定义一个单独的app.get('/'...路由。这就是"无法获取/"错误的含义。

相关内容

最新更新