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
Verified Answer
Correct Option - a

To get all Infosys Certified Node Developer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee

Telegram