To send HTML file to client with Node, we call the sendFile
method.
For instance, we write
const app = express();
app.get("/test", (req, res) => {
res.sendFile("views/test.html", { root: __dirname });
});
to call res.sendFile
with the template’s path to render the template.
root
is the root folder for the template files.