Node.js Read File from Server

Now, showing you how to create an HTTP non-blocking server and how to read a file of the non-blocking filesystem.

 var http = require('http');  
 var fs = require('fs');  
 http.createServer(function(request, response) {  
  response.writeHead(200);  
  fs.readFile('index.html', function(err, contents) {  
   response.write(contents);  
   response.end();  
  });  
 }).listen(8080);  

Generate Request

 curl http://localhost:8080  

Nikunj K

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.