Created
May 27, 2011 16:11
-
-
Save naholyr/995588 to your computer and use it in GitHub Desktop.
Embedding another application with Express
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.createServer() | |
// Configuration | |
app.configure(function() { | |
this.set('views', __dirname + '/views') | |
.set('view engine', 'jade') | |
.use(express.static(__dirname + '/public')) | |
.set('view options', {title: 'Express'}) | |
}) | |
.configure('development', function(){ | |
this.use(express.errorHandler({ dumpExceptions: true, showStack: true })) | |
}) | |
.configure('production', function(){ | |
app.use(express.errorHandler()) | |
}) | |
// Routes | |
app.get('/', function(req, res){ | |
res.render('index'); | |
}) | |
// Sub-application | |
app.use('/forum', require('forum').set('view options', { | |
title: app.set('view options').title, | |
layout: app.set('views') + '/layout.' + app.set('view engine'), | |
rootUrl: '/forum/' | |
})) | |
// Start server | |
app.listen(8080); | |
console.log("Express server listening on port %d", app.address().port); |
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
h1= title | |
p Welcome to #{title} | |
p | |
a(href="/forum") Forum |
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
!!! | |
html | |
head | |
title= title | |
link(rel='stylesheet', href='/stylesheets/style.css') | |
body!= body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment