-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (27 loc) · 1.14 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
35
/* start of file ->*/
ls = __filename.lastIndexOf('/');
rs = __filename.lastIndexOf('\\');
__filename = __filename.substring((((ls>=0)? ls + 1: 0 )| ((rs >= 0)? rs + 1: 0)), __filename.length);
console.log('['+__filename +']'+ ": starting");
exports.done = false;
/* start of file <- */
/* ----------------------------------------- */
var http = require("http");
var url = require("url");
function start(route, handle) {
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log('[' + __filename + ']' + "{export: onRequest:start}: Request for " + pathname + " received.");
response.writeHead(200, { "Content-Type": "text/plain" });
route(handle, pathname, response);
console.log('[' + __filename + ']' + "{export: onRequest:end}: Request for " + pathname + " end.");
}
http.createServer(onRequest).listen(8888);
console.log('[' + __filename + ']' + "{export}: Server has started.");
}
exports.start = start;
/* ----------------------------------------- */
/*end of file ->*/
exports.done = true;
console.log('['+__filename + ']' + ": done.");
/*end of file <-*/