WEB DEVELOPMENT PROJECT PRACTICE BACK END
Serving HTML file usinge by node js
const http = require("http");const fs = require("fs");const fileContent = fs.readFileSync("b-66.html");const hostname = '127.0.0.1';const port = 3000;const server = http.createServer((req,res)=>{res.writeHead(200,{'content-type':'text/html'});res.end(fileContent)});server.listen(port, hostname, () => {console.log(`Server running at http://${hostname}:${port}/`);});<--This is html file--><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>.box {border: 2px solid red;background-color: beige;width: 200px;height: 200px;padding: 6px;margin: 12px;}</style></head><body><div class="container"><div class="box"><h3>This is a heading</h3><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Corrupti voluptates mollitia alias, culpa non doloribus veritatis possimus quisquam?</p></div></div></body></html>
No comments