共 4 篇文章 |
|
app.get(''/'', function (req, res, next) { // 总是接收 next 参数 mysql.query(''SELECT * FROM users'', function (err, results) { // 不要这样做 if (err) throw err; // 应该将 err 传递给 errorHandler 处理 if (err) return next(err); });});app.use(function (err, req, res, next) { // 带有四个... 阅149 转0 评0 公众公开 15-08-21 10:24 |
q=0.9'' ''authorization'': _auth ''user-agent'': ''nodejs rest client''req = http.request options, (res) -> console.log(''STATUS: '' + res.statusCode) equal(200, res.statusCode) console.log(''HEADERS: '' + JSON.stringify(res.hea... 阅1460 转4 评0 公众公开 15-08-12 13:37 |
在app.js文件中,定义了app.use(‘/’, routes); routes是指向了routes目录下的index.js文件,./routes/index.js文件中,express.Router被定义使用,路径/*处理都会由routes/index.js文件里的Router来处理。~ git clone git@github.com:bsspirit/nodejs-demo.git # 下载github项目~ cd nodejs-demo # 进入下载目录~ git checkout express4 # 切... 阅36 转0 评0 公众公开 15-08-11 17:35 |
E:\project\nodejs-demo> npm start >nodejs-demo@0.0.1 start E:\project\nodejs-demo >node .E:\project\nodejs-demo> npm install bootstrapbootstrap@3.2.0 node_modules\bootstrapE:\project\nodejs-demo> npm install jqueryjquery@2.1.1 node_modules\jqueryE:\project\nodejs-demo>router.route(''/login... 阅510 转1 评0 公众公开 15-08-11 14:12 |