Skip to content

Instantly share code, notes, and snippets.

@mehdihettak
Created May 14, 2019 16:00
Show Gist options
  • Save mehdihettak/28f8ccaf26f38bfa086e93181205481d to your computer and use it in GitHub Desktop.
Save mehdihettak/28f8ccaf26f38bfa086e93181205481d to your computer and use it in GitHub Desktop.
const http = require('http');
const port = 3000;
const requestHandler = (request, response) => {
/* console.log(request.url);
response.end('Bienvenue sur votre serveur !!'); */
if (request.url === "/") {
response.end('Bienvenue sur votre serveur !!');
}
if (request.url === "/contact") {
response.end('Nous ne sommes pas joignables pour le moment !');
}
if (request.url === "/display/gerard")
response.end("Vous tentez d afficher le profil de Gerard");
}
const server = http.createServer(requestHandler);
server.listen(port, (err) => {
if (err) {
throw new Error('Something bad happened...');
}
console.log(`server is listening on ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment