Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jeremy-san/336d6107b37c5c5913a968f4989cfe35 to your computer and use it in GitHub Desktop.
Save Jeremy-san/336d6107b37c5c5913a968f4989cfe35 to your computer and use it in GitHub Desktop.
index.js
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