Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Forked from nazgob/hello_node.js
Created January 2, 2014 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/8225490 to your computer and use it in GitHub Desktop.
Save ryanburnette/8225490 to your computer and use it in GitHub Desktop.
A little node server that just gives your request back to you as JSON.
var http = require('http')
, sys = require('sys')
, server
;
server = http.createServer(function(req, res) {
var echo = {}
;
echo.headers = JSON.stringify(req.headers, true, 2);
echo.body = res;
//console.log(echo);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(echo.headers);
req.pipe(echo.body);
});
server.listen(3030);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment