read file in folder and write in browser in nodejs

this is a sample http server and read file and print in brwoser
when you call

var http = require("http");
var fs = require('fs');
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
var text= fs.readFileSync('textfile.txt', 'utf-8');

response.write(text);  response.end();


Popular posts from this blog

codefights smooth sailing ( CommonCharacterCount)

How to remove 8443 port in URL in tomcat