1 Star 0 Fork 1

zhangchengtest/expressStudy

forked from echozhangzy/expressStudy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app2.js 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
echozhangzy 提交于 2016-05-18 12:40 . blog-demo
'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);
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangchengtest/expressStudy.git
git@gitee.com:zhangchengtest/expressStudy.git
zhangchengtest
expressStudy
expressStudy
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385