代码拉取完成,页面将自动刷新
同步操作将从 echozhangzy/expressStudy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* @Author: ZhangZheyi
* @Date: 2016-05-16 10:45:40
* @Last Modified by: ZhangZheyi
* @Last Modified time: 2016-05-16 14:32:16
*/
'use strict';
var express = require('express');
var app = express();
// app.get('/', function(req, res) {
// res.send('Hello World!');
// });
//使用一个回调函数处理路由:
// app.get('/example/a', function (req, res) {
// res.send('Hello from A!');
// });
//使用多个回调函数处理路由(记得指定 next 对象):
// app.get('/example/b', function (req, res, next) {
// console.log('response will be sent by the next function ... 多个回调函数处理路由在命令控制面板输出');
// next();
// }, function (req, res) {
// res.send('Hello from B!');
// });
//使用回调函数数组处理路由:
// var cb0 = function (req, res, next) {
// console.log('CB0');
// next();
// }
// var cb1 = function (req, res, next) {
// console.log('CB1');
// next();
// }
// var cb2 = function (req, res) {
// res.send('Hello from C!');
// }
// app.get('/example/c', [cb0, cb1, cb2]);
//混合使用函数和函数数组处理路由:
var cb0 = function (req, res, next) {
console.log('CB0');
next();
}
var cb1 = function (req, res, next) {
console.log('CB1');
next();
}
app.get('/example/d', [cb0, cb1], function (req, res, next) {
console.log('response will be sent by the next function ...');
next();
}, function (req, res) {
res.send('Hello from D!');
});
var server = app.listen(3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。