-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
51 lines (41 loc) · 1.48 KB
/
app.js
File metadata and controls
51 lines (41 loc) · 1.48 KB
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
// ********************************************************
// Dependencies and Settings
// ********************************************************
var express = require('express');
var app = express();
var server = require('http').createServer(app);
app.use(express.static('public'));
// ********************************************************
// Routing
// ********************************************************
// Main view
app.get('/', function (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
// Web/Mobile app
app.get('/web', function (req, res) {
res.sendFile(__dirname + '/views/web.html');
});
// Cardboard App
app.get('/cardboard', function (req, res) {
res.sendFile(__dirname + '/views/cardboard.html');
});
// ********************************************************
// Running
// ********************************************************
server.listen(8989, function () {
console.log("*********************************************");
console.log("*** SenderoWeb listening on port 8989 ... ***");
console.log("*********************************************");
});
function exitHandler(options, err) {
server.close();
if (err) console.log(err.stack);
if (options.exit) process.exit();
}
//do something when app is closing
process.on('exit', exitHandler.bind(null,{cleanup:true}));
//catches ctrl+c event
process.on('SIGINT', exitHandler.bind(null, {exit:true}));
//catches uncaught exceptions
process.on('uncaughtException', exitHandler.bind(null, {exit:true}));