-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.coffee
51 lines (37 loc) · 1.22 KB
/
app.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
express = require 'express'
http = require 'http'
path = require 'path'
less = require 'less-middleware'
nunjucks = require 'nunjucks'
expressCoffee = require 'express-coffee'
app = express()
serverURL = 'localhost:3000'
if process.env.serverURL?
serverURL = process.env.serverURL
app.configure ->
env = new nunjucks.Environment(new nunjucks.FileSystemLoader('templates'))
env.express(app)
app.use express.errorHandler()
app.use expressCoffee
path: __dirname + '/public'
live: !process.env.PRODUCTION
uglify: process.env.PRODUCTION
app.use less
src: path.join __dirname, 'public'
once: false
app.use express.favicon __dirname + '/public/images/favicon.ico'
app.use express.static __dirname + '/public'
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.get '/', (req, res)->
res.render 'index.html', index:true
app.get '/about', (req, res)->
res.render 'about.html', about:true
app.get '/contact', (req, res)->
res.render 'contact.html', contact:true
app.use (req, res)->
res.status 404
res.send '404 - Could not find resource'
http.createServer(app).listen process.env.PORT or 3000
console.log "Server running - on port " +(process.env.PORT or 3000)