-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapp.js
37 lines (34 loc) · 1.18 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
var express = require('express');
var request = require('request');
var app = express();
/*app.get('/', function(req, res){
res.send('Hello World!');
});*/
var regions = ['us', 'ca', 'au', 'uk'];
app.set('view engine', 'jade');
app.get('/', function(req, res){
var region = 'us';
res.render('index', {region: region, query: (req.query.q) ? req.query.q : ""});
})
app.get('/us', function(req, res){
res.render('index', {region: 'us', query: (req.query.q) ? req.query.q : ""});
})
app.get('/ca', function(req, res){
res.render('index', {region: 'ca', query: (req.query.q) ? req.query.q : ""});
})
app.get('/uk', function(req, res){
res.render('index', {region: 'uk', query: (req.query.q) ? req.query.q : ""});
})
app.get('/au', function(req, res){
res.render('index', {region: 'au', query: (req.query.q) ? req.query.q : ""});
})
app.use('/', express.static('public', { maxAge: 86400000 }));
app.use(function(req, res, next) {
res.status(404).send('File Not Found');
});
var port = process.env.PORT || 3000;
var server = app.listen(port, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});