Created
June 19, 2014 00:28
-
-
Save mcwhittemore/44275c75c1ddd4f7b064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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