Skip to content

Instantly share code, notes, and snippets.

@angelochen960
Created June 10, 2012 09:52
Show Gist options
  • Save angelochen960/2904717 to your computer and use it in GitHub Desktop.
Save angelochen960/2904717 to your computer and use it in GitHub Desktop.
CoffeeScript sample using expressjs 3 and Swig template
express = require 'express'
routes = require './routes'
http = require 'http'
cons = require 'consolidate'
app = express()
app.engine 'html', cons.swig
app.configure ( ->
app.set 'port', process.env.PORT || 3000
app.set 'views', __dirname + '/views'
app.set 'view engine', 'html'
app.use express.favicon()
app.use express.logger('dev')
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.use express.static(__dirname + '/public')
)
app.configure('development', ->
app.use express.errorHandler()
require('swig').init { cache: false }
)
app.get '/', routes.index
http.createServer(app).listen(app.get('port'), ->
console.log "Express server listening on port " + app.get('port')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment