-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (24 loc) · 865 Bytes
/
server.js
File metadata and controls
31 lines (24 loc) · 865 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
/* Created by durka on 12/30/16. */
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('Request for ' + pathName + ' received.');
route(handle, pathName, response, request);
}
http.createServer(onRequest, function (q, r) {
if (q.url === '/favicon.ico') {
r.writeHead(200, {'Content-Type': 'image/x-icon'});
r.end();
console.log('favicon requested');
return;
}
console.log('hello');
r.writeHead(200, {'Content-Type': 'text/plain'});
r.write('favicon test past..');
r.end();
}).listen(8000);
console.log('Server has started. Listening on port: 8000' + '...');
}
exports.start = start;