代码拉取完成,页面将自动刷新
同步操作将从 echozhangzy/expressStudy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'use strict';
//app.mountpath 挂接
var express = require('express');
// var app = express(); // the main app
// var admin = express(); // the sub app
// app.get('/', function(req, res) {
// res.send('Hello World!');
// });
// admin.get('/', function (req, res) {
// console.log(admin.mountpath); // /admin
// res.send('Admin Homepage');
// })
// app.use('/admin', admin); // mount the sub app
//
var app = express();
app.get('/', function(req, res) {
res.send('Hello World!');
});
var admin = express();
admin.get('/', function (req, res) {
console.log(admin.mountpath); // [ '/adm*n', '/manager' ]
res.send('Admin Homepage');
})
var secret = express();
//Events
//app.on('mount', callback(parent))
secret.on('mount', function (parent) {
console.log('secret Mounted 打印信息下面是父');
console.log(parent); // refers to the parent app
});
secret.get('/', function (req, res) {
console.log(secret.mountpath); // /secr*t
res.send('Admin Secret');
});
admin.use('/secr*t', secret); // load the 'secret' router on '/secr*t', on the 'admin' sub app
app.use(['/adm*n', '/manager'], admin); // load the 'admin' router on '/adm*n' and '/manager', on the parent app
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);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。