Permalink
Browse files

라우트 쪼개기 2 예제

  • Loading branch information...
egoing committed May 7, 2016
1 parent 42b701e commit c596a091b292a25a652564ab1fc602ee0008db1a
Showing with 20 additions and 14 deletions.
  1. +2 −14 app_routes.js
  2. +9 −0 routes/p1.js
  3. +9 −0 routes/p2.js
View
@@ -1,22 +1,10 @@
var express = require('express');
var app = express();
var p1 = express.Router();
p1.get('/r1', function(req, res){
res.send('Hello /p1/r1');
});
p1.get('/r2', function(req, res){
res.send('Hello /p1/r2');
});
var p1 = require('./routes/p1');
app.use('/p1', p1);
var p2 = express.Router();
p2.get('/r1', function(req, res){
res.send('Hello /p2/r1');
});
p2.get('/r2', function(req, res){
res.send('Hello /p2/r2');
});
var p2 = require('./routes/p2');
app.use('/p2', p2);
app.listen(3003, function(){
View
@@ -0,0 +1,9 @@
var express = require('express');
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p1/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p1/r2');
});
module.exports = route;
View
@@ -0,0 +1,9 @@
var express = require('express')
var route = express.Router();
route.get('/r1', function(req, res){
res.send('Hello /p2/r1');
});
route.get('/r2', function(req, res){
res.send('Hello /p2/r2');
});
module.exports = route;

0 comments on commit c596a09

Please sign in to comment.