因此,Im开始使用Node.js。 我在上看到了与Ryan Dahl的录像,并听到他建议为网站提供快车。
我下载了最新版本的快递,并开始编码。 我对......有完全成熟的静态看法,但一旦我尝试派遣参数,我就会发现这样的错误:
Cannot GET /wiki
我在“上尝试过,但最新版本中一个使用路线的改变使指南无法使用。
指南:
app.get( /users/:id? , function(req, res, next){
var id = req.params.id;
if (id) {
// do something
} else {
next();
}
});
Generated by Express:
app.get( / , routes.index);
My problem arises when I try and add another route.
app.get( /wiki , routes.wiki_show);
我尝试了一套办法,但我保留了<代码>。 Cannot GET /wiki (404) 差错。
routes/index.js looks like this:
exports.index = function(req, res) {
res.render( index , { title: Test , articles: articles, current_article: current_article, sections: sections })
};
The only thing I did there was add some parameters (arrays in the same file) and this i working. But when I copy the contents and change exports.index
to exports.wiki
or exports.wiki_show
I still get the Cannot GET /wiki
error.
Can anyone explain to me what I m missing here? - Thanks.