nodeJs学习-13 router
const express=require(‘express‘); var server=express(); //目录1:/user/ var routeUser=express.Router(); routeUser.get(‘/1.html‘, function (req, res){ //http://xxx.com/user/1.html res.send(‘user1‘); }); routeUser.get(‘/2.html‘, function (req, res){ //http://xxx.com/user/2.html res.send(‘user22222‘); }); server.use(‘/user‘, routeUser); //目录2:/article/ var articleRouter=express.Router(); server.use(‘/article‘, articleRouter); articleRouter.get(‘/10001.html‘, function (req, res){ //http://xxxx.com/article/10001.html res.send(‘asdfasdfasdf‘); }); server.listen(8080);
相关推荐
JamesRayMurphy 2020-05-25
starzhangkiss 2020-04-19
普罗旺斯的梦 2020-04-09
始作俑者 2020-01-19
普罗旺斯的梦 2020-01-01
xyggsddu 2019-12-26
aihenaichadeyun 2019-12-20
rareli 2019-12-16
始作俑者 2019-12-13
fm00 2019-11-01
普罗旺斯的梦 2019-09-13
普罗旺斯的梦 2019-09-06
kaikai 2018-11-28
范群松 2019-08-30
codingker 2019-07-11
fuziwang 2019-07-01
sunwukong 2019-06-30
普罗旺斯的梦 2019-06-29