forked from drichard/mindmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (24 loc) · 823 Bytes
/
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
var sys = require('util');
var static = require('node-static');
// resolve debug or production path
var path = 'src';
var args = process.argv;
if (args.length >= 3 && args[2] == '--production') {
path = 'bin';
}
var file = new(static.Server)(path, { cache: false });
require('http').createServer(function (request, response) {
request.addListener('end', function () {
file.serve(request, response, function (err, res) {
if (err) {
sys.error("> Error serving " + request.url + " - " + err.message);
response.writeHead(err.status, err.headers);
response.end();
} else {
sys.puts("> " + request.url + " - " + res.message);
}
});
});
}).listen(8080);
sys.puts("> node-static is listening on http://127.0.0.1:8080");
sys.puts("> and serving path: /" + path);