我正在开发一个小型Node应用程序,并且一切正常。它需要从目录/source
提供一些静态文件。
今天,在计算机重新启动后,当我访问本地站点时,得到的只是Cannot GET /
。自从上次工作以来,Node config中的任何内容都没有改变。
var express = require('express'),
app = express(),
path = require('path'),
fs = require('fs');
// Load our static site to start with
app.use(express.static(path.join(__dirname, 'source')));
// Start the node server
app.listen(3000, function() {
var host = this.address().address,
port = this.address().port;
console.log('Serving Atenium at http://%s:%s', host, port);
});
我的文件夹如下所示:
|- app/
|-- index.js
|- source/
|-- <static files>
关于为什么这只是停止工作的任何想法?
最佳答案
您可以在此过程中更新快递模块吗?我相信在Express 4中,静态内容现在由在https://github.com/expressjs/serve-static中找到的serve-static中间件库处理。