const http = require('http');
const port = 3000;
const requestHandler = (request,response) => {
let name = request.url.split('/')[2]
if (request.url === "/") {
response.end('Bienvenue sur notre serveur')
}else if(request.url ==="/contact"){
response.end('Nous ne sommes pas joignables pour le moment')
}else if(request.url ===`/display/${name}`) {
response.end(`Vous tentez d'afficher le profil de ${name}`)
}else {
response.end("Error 404")
}
}
const server = http.createServer(requestHandler)
server.listen(port,(err) => {
if (err) {
throw new Error("Error")
}
console.log(`Sever started sur le port : ${port}`);
});