Skip to content

Instantly share code, notes, and snippets.

@keithchambers
Created October 9, 2014 16:29
Show Gist options
  • Save keithchambers/2b77be3e2cc37098e41d to your computer and use it in GitHub Desktop.
Save keithchambers/2b77be3e2cc37098e41d to your computer and use it in GitHub Desktop.
nodejs hello world
var http = require('http');
var port = 8080;
var args = process.argv.splice(2);
if (args.length > 0) {
port = args[0];
}
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain', 'Cache-Control': 'no-cache'});
res.end('Hello, world.');
}).listen(port, "");
console.log('Server running at port: ' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment