因此開始要切割程序
1.導入外部程序
1-1.
在routes裡建立extern.js
exports.index = function(req, res, next) {
res.send("respond with a extern index");
};
1-2.
在app.js
加上
extern = require('./routes/extern')
也加上app.getapp.get('/extern', extern.index);
app.get('/extern/*', extern.index);
將所有有關extern都導向extern.index的function之後在做其他的切割
1-3.
這樣所有有關extern都導向extern.js中的index
2.判斷params
express在使用*來做引導
引導之後會將判斷剩下來的
除了GET值之外存到params[0]裡
因此將params[0]做spilt
就可以再次延伸route
2-1.
在routes.js
改成
exports.index = function(req, res, next) {
if (req.params[0] == null) {
res.send("respond with a extern index");
} else {
var params = req.params[0].split("/");
if (params[0] == "func1") {
func1(req, res, next);
} else {
res.send("respond with a extern no function");
}
}
};
function func1(req, res, next) {
res.send("respond with a extern func1");
};
2-2.








2 意見:
h810c7gsggd246 vibrating dildos,sex chair,vibrators,Discreet Vibrators,dildo,realistic vibrators,dildos,male sex doll,prostate massagers j545j2lyyps571
z336x6ujzuo931 vibrators,Rabbit Vibrators,vibrators,wholesale sex toys,sex toys,horse dildos,realistic dildos,horse dildos,sex dolls v524v5jigxu811
張貼留言