-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_UI_HTTP.js
More file actions
38 lines (23 loc) · 817 Bytes
/
server_UI_HTTP.js
File metadata and controls
38 lines (23 loc) · 817 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
var http = require("http");
var url = require("url");
function start_UI_HTTP(port, route, handle) {
function onRequest( req, res ) {
var postData = "";
var pathname = url.parse(req.url).pathname;
console.log("SERVER: Request Received.");
console.log("SERVER: request path: " + pathname );
req.setEncoding("utf8");
req.addListener("data", function(postDataChunk) {
postData += postDataChunk;
console.log("Received POST data chunk '"+ postDataChunk + "'.");
});
req.addListener("end", function() {
console.log(postData);
var data = JSON.parse( postData );
route(pathname, res, handle, data);
});
}
http.createServer(onRequest).listen(port);
console.log("Server Started on port: " + port );
}
exports.start_UI_HTTP = start_UI_HTTP;