我正在研究一個小型的Node應用程序,並且工作正常。它需要服務於目錄/source
的一些靜態文件。Node.js和Express:「無法GET /」靜態網站
今天,在電腦重啓後,當我訪問我的本地網站時,我所得到的全部是Cannot GET /
。自上次工作以來,節點配置中沒有任何更改。
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>
任何想法,爲什麼這個剛剛停止工作?
是否有'source/index.html'文件或任何東西? – 2015-02-23 18:15:19
是的,'source /'目錄有一個'index.html'文件。 – jnettik 2015-02-23 18:21:35
您能否請您證明您的路線定義在哪裏? – NarendraSoni 2015-02-24 02:35:32