Skip to content

Instantly share code, notes, and snippets.

@DarrylDias
Last active January 2, 2016 11:39
Show Gist options
  • Save DarrylDias/8297843 to your computer and use it in GitHub Desktop.
Save DarrylDias/8297843 to your computer and use it in GitHub Desktop.
Hello World that displays console log on every new client's connection
var http = require('http');
http.createServer(function(request,response) {
response.writeHead(200, {'Content-Type':'text/plain'});
response.end("Hello World!\n"); // "Hello World!" will be displayed to the client's browser
console.log("New page request!\n"); // message will be displayed with every new request
}).listen(8000); //Node web server port. Edit it to your preferd port.
console.log("Node web server running at http://127.0.0.1:8000");
console.log("CTRL + C to stop the Node web server");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment