-
-
Save ayoungh/6666dcc5f28d496d8441 to your computer and use it in GitHub Desktop.
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express"); | |
var app = express(); | |
app.get('/', function (req, res) { | |
res.send("This is the '/' route in ep_app"); | |
}); | |
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var express = require("express"); | |
var app = express(); | |
var ep_app = require("./ep_app"); | |
app.use('/ep_app', ep_app); | |
app.get('/', function (req, res) { | |
res.send("This is the '/' route in main_app"); | |
}); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment