Web applications commonly have to handle forms in which the user can enter data that need to be processed. Consider the scenario where a login form (login.html)is to be displayed to the user on request. What will be the correct code snippet for implementing this in server.js file in a Node.js application.

exports.login=function(url,request,response) {
                 fs.readFile('./login.html', function (err, html) {
                     if (err) {
                                  throw err; 
                                 }       
                    response.writeHeader(200, {"Content-Type": "text/html"})
                     response.write(html);  
                     response.end();  
                 });
  }
exports.login=function(url,request,response) {
                fs.write('./login.html', function (err, html) {
                              if (err) {
            throw err; 
      }       
                response.writeHeader(200, {"Content-Type": "text/html"});  
               });
}
exports.login=function() {
                 response.writeHeader(200, {"Content-Type": "text/html"});  
                 response.write(login.html);  
                 response.end(); 
}
It is not possible to send an HTML page from node server
Correct Option - a

To get all Infosys Certified Node Developer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in