-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
52 lines (42 loc) · 1.25 KB
/
app.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
43
44
45
46
47
48
49
50
51
52
/*
* Declare module dependencies
*/
var express = require('express'),
fs = require('fs'),
hbs = require('hbs'),
app = express();
/*
* Configure Express framework
*/
app.configure(function() {
app.use(express.static('images'));
app.use(express.static('scripts'));
app.use(express.static('styles'));
app.use(express.favicon('images/favicon_32x32.ico'));
app.use(express.logger('tiny'));
app.engine('html', hbs.__express);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(express.bodyParser());
});
/*
* Register Handlebars partials
*/
//Without encoding, readFileSync() returns buffer, not string
hbs.registerPartial('footer', fs.readFileSync(__dirname + '/views/footer.html', 'utf8'));
hbs.registerPartial('head', fs.readFileSync(__dirname + '/views/head.html', 'utf8'));
hbs.registerPartial('map_script', fs.readFileSync(__dirname + '/views/map_script.html', 'utf8'));
hbs.registerPartial('nav', fs.readFileSync(__dirname + '/views/nav.html', 'utf8'));
/*
* Define URL routes (controllers)
*/
require('./controllers/controller')(app);
/*
* Start Express
*/
if(app.settings.env == 'production') {
var port = process.env.PORT || 5000;
} else {
var port = 9999;
}
app.listen(port, "0.0.0.0", function() { });