-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.js
42 lines (34 loc) · 1.01 KB
/
server.js
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
var fs = require('fs');
var path = require('path');
var express = require('express');
var cheerio = require('cheerio');
var nct = require('nct');
var Backbone = require('backbone');
Backbone.$ = cheerio
module.exports = app = express()
app.configure(function() {
app.use(express.logger('dev'));
});
app.configure('production', function() {
app.use(express.static(__dirname+'/release'));
});
app.configure(function() {
app.use(express.static(__dirname+'/www'));
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
});
// app.get('/js/*', function(req, res) {
// res.send(404);
// });
app.get('/*', function(req, res) {
var layout = fs.readFileSync(path.join(__dirname, 'app/templates/layout.nct'), 'utf8')
var html = nct.renderTemplate(layout, {production: process.env.NODE_ENV=='production'})
res.send(html);
});
// Run the server if it is run directly
if (!module.parent) {
app.listen(3010);
console.log( "listening on port: 3010");
}