#13 Sending HTML Response | Fundamentals of NODE JS | A Complete NODE JS Course

preview_player
Показать описание
In the last lecture we learned how to define routes in NODE JS and send different responses for different URLs. In this lecture let's see how we can send HTML response from NODE JS server.

Рекомендации по теме
Комментарии
Автор

perhaps best node.js playlist on bhaiya explained everything....❤❤❤

himanshujha
Автор

I really appreciate they way you have put the Html File separately, Thanks

Hostundefined
Автор

If for anyone an error pops out saying replace is not a function then you must have forgotten to add utf-8 encoding to the readfilesync function .

check with it

chaitanyakarthik
Автор

Node js doesn't serve static files automatically 😢

PollyMwangi-cpjn
Автор

The replace method is not working, shows .replace ins not a function

MinuteTechMallu
Автор

For those who got errors where the terminal throws errors with replace function, try to add encoding to readFileSync like.

const html = fs.readFileSync("./Template/index.html", "utf-8");
// thanks to people who comments before me.

Alternatively, I discovered that we can also add toString() method before "replace":

response.end(html.toString().replace("{{%CONTENT%}}", "...."));
// not sure if this is a good fix though, but it is working for me.

JoeKalmaPhilips