Created
June 7, 2012 13:23
-
-
Save sunnygleason/2888796 to your computer and use it in GitHub Desktop.
node.js http servers suitable for debugging
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'); | |
| http.createServer(function (req, res) { | |
| console.log(req); | |
| var body = ''; | |
| req.on('data', function (data) { body += data; }); | |
| req.on('end', function () { | |
| console.log('body', body); | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| res.end('service the first\n'); | |
| }); | |
| }).listen(9090, "127.0.0.1"); | |
| http.createServer(function (req, res) { | |
| console.log(req); | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| req.on('end', function () { | |
| console.log('body', body); | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); | |
| res.end('service the second\n'); | |
| }); | |
| ).listen(9190, "127.0.0.1"); | |
| console.log('Server running at http://127.0.0.1/ port 9090 and 9190'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment