Skip to content

Instantly share code, notes, and snippets.

@naholyr naholyr/app.js
Created May 27, 2011

Embed
What would you like to do?
Embedding another application with Express
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);
h1= title
p Welcome to #{title}
p
a(href="/forum") Forum
!!!
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
You can’t perform that action at this time.