Node.js

Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

i’ve been learning about Node.js, which is basically Javascript on the server. You can write an entire website, including the web server itself with Node.js. This little file implements a web server and write out “Hello World”!

var http = require("http");

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);

After you’ve installed Node.js (see here for download: http://nodejs.org/download/ or you can use your favorite package manager) you run this file, open your broswer to http://yoursite.com:8888 and you’ll see the message. Pretty simple, huh?


Share the joy
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply