-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.js
59 lines (45 loc) · 1.26 KB
/
web.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
53
54
55
56
57
58
59
// serves static files, in dev also re-makes project
var express = require('express');
var spawn = require('child_process').spawn;
var app = express();
/*
// run make to update if request is for development
app.use(function(req, res, next) {
var isDev = (req.url.indexOf('dev.html') != -1);
//(req.url.indexOf('index.html') != -1);
var isDist = false;
var makeDist = '';
if (isDev) {
makeDist = 'dev';
}
if (isDist) {
makeDist = 'dist';
}
if (isDev || isDist) {
var make = spawn('make', [makeDist]);
var standardError = new String();
make.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
make.stderr.on('data', function (data) {
console.log('stderr: ' + data);
standardError += data;
});
make.on('close', function (code) {
console.log('child process exited with code ' + code);
if (0 === code) {
next();
} else {
res.send('<pre>' + standardError + '</pre>');
}
});
} else {
next();
}
});
*/
// serve all files from public dir using built-in static file server
app.use(express.static(__dirname + '/public'));
var port = process.env.PORT || 3001;
var expressServer = app.listen(port);
console.log('Listening for web on port', port);