Created
May 17, 2019 15:24
-
-
Save Jeremy-san/336d6107b37c5c5913a968f4989cfe35 to your computer and use it in GitHub Desktop.
index.js
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) | |
res.writeHead(200, { "Content-Type": "text/plain ; charset=utf-8" }) | |
console.log(name) | |
if (page == "/") { | |
res.write("Vous êtes à l'accueil, que puis-je pour vous ?") | |
} else if (page == "/soussol") { | |
res.write("Vous êtes dans la cave à vins, ces bouteilles sont à moi !") | |
} else if (page == `/display/${name}`) { | |
res.write(`page de ${name}`) | |
} else if (page == "/etage/1/chambre") { | |
res.write("Hé ho, c'est privé ici !") | |
} | |
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