Posts Tagged ‘Node’

Node.JS one-line header echo

Coding []

Here’s a simple one-line Node-based Web server that just echos your browser’s request headers:

node -e "require('http').createServer(function(q,a){a.writeHead(200,{'Content-Type':'text/plain'});a.end(JSON.stringify(q.headers,null,' '));}).listen(12345,'127.0.0.1');"

Navigate to http://myServer:12345/ and observe your browser’s request headers. (The line probably wraps in your browser, but it’s just one line, honestly.)