Last active
March 25, 2022 12:36
-
-
Save rasolofonirina/f103eb7430323e26b31b509a986ba929 to your computer and use it in GitHub Desktop.
URL with content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
const url = require('url') | |
const server = http.createServer((req, res) => { | |
const page = url.parse(req.url).pathname | |
console.log(page) | |
res.writeHead(200, {"Content-Type": "text/plain"}) | |
if (page == '/') { | |
res.write('Home') | |
} | |
else if (page == '/about') { | |
res.write('About us') | |
} | |
else if (page == '/contact') { | |
res.write('Contact us') | |
} | |
res.end() | |
}) | |
server.listen(8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment