Created
April 25, 2011 06:43
-
-
Save marlun/940239 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'), | |
| 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