Created
October 9, 2014 16:29
-
-
Save keithchambers/2b77be3e2cc37098e41d to your computer and use it in GitHub Desktop.
nodejs hello world
This file contains 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'); | |
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