How to using html page in nodejs code

 var http = require('http'),

    fs = require('fs');



fs.readFile('./index.html', function (err, html) {

    if (err) {

        throw err; 

    }       

    http.createServer(function(request, response) {  

        response.writeHeader(200, {"Content-Type": "text/html"});  

        response.write(html);  

        response.end();  

    }).listen(8000);

});

Comments

Popular posts from this blog

How to create a node JS start server