1
你好我想顯示的消息:從文件夾航線資源響應/ user.js的res.Send它導致404錯誤?
exports.list = function (req, res) {
res.send("respond with a resource");
};
但我得到一個錯誤404在命令prompt.And在URL 本地主機:8080 \用戶,其中發送響應我得到的消息:
不能得到/用戶
我app.js具有代碼:
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/users', user.list);
http.createServer(app).listen(app.get('port'), function() {
console.log('Express server listening on port ' + app.get('port'));
});
我正在從事的示例是從https://www.youtube.com/watch?v=czmulJ9NBP0。時間是1.37.41
我建議改爲app.get('/ user',user.list); – Gary
謝謝你..這工作 –