【发布时间】:2015-02-18 10:51:38
【问题描述】:
我对 Node.js 还很陌生,但 StrongLoop Docs 并没有真正给出任何具体的例子。我正在为我的模板使用 Handlebars,我只是想提供一个标准的 index.js 预编译模板。我知道我应该编辑我的routes.js 文件,但我不知道该怎么做。
这是我的routes.js 文件的样子:
module.exports = function(app) {
// I need this to serve my index.js file.
app.get('/', function(req, res) {
// Doesn't work, so I commented it out:
// require('views/index.js');
// Doesn't work, so I commented it out:
// res.requires('views/index.js');
// Doesn't work, so I commented it out:
// res.send('views/index.js');
// What do I put here then?
});
// This is the generic example. Just sends text.
app.get('/ping', function(req, res) {
res.send('pong');
});
};
澄清一下,当我说它不起作用 TM 时,我的意思是输入 localhost 会显示 404 包罗万象的路线。是的,那是localhost,而不是localhost:3000。它在端口 80 上工作。
【问题讨论】:
-
你找到答案了吗?我正在尝试将骨架环回应用程序转换为全栈应用程序/api 服务器(可以从服务器外部和内部访问数据)。
标签: javascript node.js strongloop