use node js
Mon Jun 12 2023 17:42:22 GMT+0000 (Coordinated Universal Time)
Saved by
@danishyt96
#javascript
first npm init
second npm i express nodemon
const http = require("http");
const fs = require("fs");
const home = fs.readFileSync("./index.html", "utf-8");
const server = http.createServer((req, res) =>{
if(req.url === "/"){
return res.end(home);
}
});
const PORT = 4000;
const hostname = "localhost";
server.listen(PORT, hostname, () =>{
console.log("Server is working");
});
content_copyCOPY
Comments