-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
47 lines (39 loc) · 1.1 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
var path = require('path'),
bodyParser = require('body-parser'),
express = require('express'),
fs = require('fs'),
locations = require('./locations/locations');
var app = express();
app.use(express.static('public'));
app.use('/bower_components', express.static(__dirname + '/bower_components'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.set('view engine', 'pug');
app.set('views', path.resolve('public/views'));
app.get('/', function(req, res) {
res.render('index', {
locations: JSON.stringify(locations)
});
});
app.get('/about', function(req, res) {
res.render('about');
});
app.get('/easteregg', function(req, res) {
res.render('easteregg');
});
app.get('/search/:loc', function(req, res) {
var position = null;
if (req.params.loc) {
// verify min format, i.e., comma separated values
position = req.params.loc.split(',');
}
res.render('default', {
locations: JSON.stringify(locations),
position: position
});
});
app.listen(process.env.PORT || 3000, function() {
console.log('Example app listening on port 3000!');
});