-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
48 lines (39 loc) · 1.34 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
43
44
45
46
47
48
var port = 1337;
var port2 = 1338;
var express = require('express');
var bodyParser = require('body-parser');
var https = require('https');
var http = require('http');
var fs = require('fs');
var options = {
key : fs.readFileSync('server/server.key'),
cert : fs.readFileSync('server/server.crt')
};
var app = express();
// view engine
//app.set('views', express.static(__dirname, '/views'));
app.set('view engine', 'pug');
app.engine('html', require('pug').renderFile);
// set static folders
app.use('/js', express.static(__dirname + '/js'));
app.use('/css', express.static(__dirname + '/css'));
app.use('/images', express.static(__dirname + '/images'));
app.use('/github', express.static(__dirname + '/github'));
// body parser middleware
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
var index = require('./routes/index');
var destinations = require('./routes/destinations');
app.use('/', index);
app.use('/api', destinations);
// thing for Brandon's server to update
app.post('/update', function(req, res) {
console.log("got a post");
var sys = require('sys');
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout); }
exec("sh github/update.sh", puts);
});
https.createServer(options, app).listen(port, function(){
console.log('Server running at https://localhost:' + port);
});