Skip to content

Instantly share code, notes, and snippets.

@watert
Last active December 19, 2015 20:59
Show Gist options
  • Save watert/6017215 to your computer and use it in GitHub Desktop.
Save watert/6017215 to your computer and use it in GitHub Desktop.
Basic server based on coffee-script & express & underscore
###== Basic server based on coffee-script & express ==
# run by forever:
sudo forever -w -c coffee server.coffee
###
_ = require("underscore")._
express = require "express"
app = express()
console.log "\n--- BEGIN --- @ " + new Date()
### Config Part ###
publicDir = __dirname + '/public'
app.use(express.static(publicDir))
app.use(express.bodyParser())
app.use(express.cookieParser())
app.use(express.session( secret:"watert's links" ))
### Views Part ###
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.set('view options', { layout: false })
app.set('view cache', false )
ejs = _.extend require('ejs'),open:"{{",close:"}}"
app.engine('.html', ejs.renderFile)
app.port = 3001
console.log "Start Listening to "+app.port
app.listen app.port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment