Skip to content

Instantly share code, notes, and snippets.

@hayleyxyz
Created January 26, 2015 19:59
Show Gist options
  • Save hayleyxyz/5734c474f72967bad805 to your computer and use it in GitHub Desktop.
Save hayleyxyz/5734c474f72967bad805 to your computer and use it in GitHub Desktop.
node.js http server
var http = require('http');
if(process.argv.length < 3) {
console.error('Missing listen address argument');
return;
}
var listenAddress = process.argv[2];
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write(listenAddress);
res.end();
});
server.listen(80, listenAddress);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment