Skip to content

Instantly share code, notes, and snippets.

@mcwhittemore
Created June 19, 2014 00:28
Show Gist options
  • Select an option

  • Save mcwhittemore/44275c75c1ddd4f7b064 to your computer and use it in GitHub Desktop.

Select an option

Save mcwhittemore/44275c75c1ddd4f7b064 to your computer and use it in GitHub Desktop.
var http = require('http');
var simserver = http.createServer(function (req, res) {
//console.log('req.url:', req.url);
res.writeHead(200, {'Content-Type': 'text/plain'});
var count = 10;
var timerId = setInterval(function() {
console.log('request count:', count);
count = count -1;
if (count > 0) {
res.write(count + ' ');
} else {
res.end('okay');
clearInterval(timerId);
}
}, 1000);
});
var portNumber = 8910;
simserver.listen(portNumber, '127.0.0.1', function() {
console.log('server listens on ' + portNumber);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment