forked from AugurProject/augur-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (23 loc) · 776 Bytes
/
server.js
File metadata and controls
37 lines (23 loc) · 776 Bytes
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
// basic node-static server wrapper for app
var static = require('node-static'),
http = require('http'),
util = require('util');
var webroot = './app',
port = process.env.PORT || 8080
var file = new(static.Server)(webroot, { cache: 600 });
http.createServer(function(req, res) {
// static URIs
var re = /\/(css|images|augur\.js)/;
// route to app if not static URI
if (!req.url.match(re)) req.url = '/augur.html';
file.serve(req, res, function(err, result) {
if (err) {
console.error('Error serving %s - %s', req.url, err.message);
res.writeHead(err.status, err.headers);
res.end();
} else {
console.log('%s', req.url);
}
});
}).listen(port);
console.log('node-static running at http://localhost:%d', port);