Skip to content

Instantly share code, notes, and snippets.

@marlun
Created April 25, 2011 06:43
Show Gist options
  • Select an option

  • Save marlun/940239 to your computer and use it in GitHub Desktop.

Select an option

Save marlun/940239 to your computer and use it in GitHub Desktop.
var express = require('express'),
app = express.createServer(),
jam = require('./jam');
app.set('views', __dirname + '/templates');
app.set('view engine', 'html');
app.register('.html', require('ejs'));
app.use(express.static(__dirname + '/public'));
app.use(express.logger());
app.use(express.bodyParser());
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.use(jam({ patterns: ['*.html'] }));
// Routes
app.get('/', function(req, res) {
res.render('home');
});
app.get('/reqs', function(req, res) {
console.log('Test test test');
res.send([
{id: 1, title: 'Do this'},
{id: 2, title: 'Do that'}
]);
});
// Don't listen when app is imported (required)
if (!module.parent) {
app.listen(3000);
console.log("Express server listening on http://localhost:%d", app.address().port);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment