using node.js to read html file and send html response code example
Example: read html file node js
const http = require("http");
const fs = require("fs");
const hostname = "127.0.0.1";
const port = 3000;
const files = fs.readFileSync("new.html");
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
res.end(files);
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
console.log("Done")
});