http server node example
const http = require("http");
const server = http.createServer((req, res) => {
console.log(req.url);
if (req.url === "/") {
res.write("<h1>This is home page</h1>");
} else if (req.url === "/about") {
res.write("<h1> This is about page </h1>");
} else if (req.url === "/contact") {
res.write("<h1>This is contact page</h1>");
} else {
res.write("<h1>Page not found</h1>");
}
res.end();
});
server.listen(3000, () => {
console.log("server is running");
});