-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (30 loc) · 1.04 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
var static = require('node-static');
var jsonProducer = require("./json-producer");
//
// Create a node-static server instance to serve the './public' folder
//
var file = new (static.Server)('./src/main/resources', {headers:
{
"Access-Control-Allow-Origin": "*"
}});
var testFile = new (static.Server)('./src/test/resources');
var json = new (jsonProducer.Server)("hourreg");
require('http').createServer(
function (request, response) {
request.addListener('end', function () {
if (request.url.match(/\/?hourreg\/.*/)) {
console.log("Serving JSON")
json.serve(request, response);
} else {
console.log("Serving " + request.url);
file.serve(request, response);
}
});
}).listen(8079);
require('http').createServer(
function (request, response) {
request.addListener('end', function () {
console.log("Serving " + request.url);
testFile.serve(request, response);
});
}).listen(8081);