Starting with Node.js

For creating a new product for my company, I had to dive into Node.js. And wow, what simple it is!

Found http://www.nodebeginner.org/#hello-world and was able to create a simple app in minutes. Look how simple:

var http = require("http");
var url = require("url");

function start() {
  function onRequest(request, response) {
    var pathname = url.parse(request.url).pathname;
    console.log("Request for " + pathname + " received.");
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Hello World");
    response.end();
  }

  http.createServer(onRequest).listen(8888);
  console.log("Server has started.");
}

exports.start = start;

The tutorial explains asynchronous handling very well, making above example very logical.

The real problem now is that I find lots and lots of new solutions for current problems.

 

Leave a Reply

Your email address will not be published. Required fields are marked *