Created
May 15, 2019 13:15
-
-
Save JonesCharly/beff3bc06e5ba410a221a61630c7766d to your computer and use it in GitHub Desktop.
Node.quete 2
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 port = 3000 | |
const server = http.createServer((req, res) => { | |
const page = url.parse(req.url).pathname | |
let name = page.slice(9) | |
console.log(name) | |
if (page == "/") { | |
res.write("Bienvenue sur votre serveur !!") | |
} else if (page == "/contact") { | |
res.write("Nous ne sommes pas joignables pour le moment !") | |
} else if (page == `/display/${name}`) { | |
res.write(`Vous tentez d’afficher le profil de ${name}`) | |
} | |
res.end() | |
}) | |
server.listen(port) | |
console.log("http://localhost:3000") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment