-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 804 Bytes
/
app.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
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
if (req.url === '/favicon.ico') {
return res.end();
}
console.log('Incoming request to ' + req.url);
var i = 2;
res.writeHead(200,{'Content-Type': 'text/plain'});
setTimeout(function () {
fs.readFile(__filename, {
encoding: 'utf8'
}, function (error, contents) {
if (error){
console.error(error);
return res.end();
}
console.log('sending response for ' + req.url);
res.end(contents);
});
},5000)
while (i--){
console.log('Loop value: ' + i + '\r');
}
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');