Created
May 17, 2019 10:45
-
-
Save JonesCharly/13083e28fd3088fd2a841a4fe8fe5d65 to your computer and use it in GitHub Desktop.
Express n*1
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 express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/', (request, response) => { | |
response.send('Bienvenue sur Express Project'); | |
}); | |
app.get('/api/movies', (request, response) => { | |
response.send('Récupération de tous les films'); | |
}); | |
app.get('/api/movies/:id', (request, response) => { | |
const id = request.params.id; | |
response.json({id}); | |
}); | |
app.get('/api/employee', (request, response) => { | |
const name = request.query.name; | |
if (name == undefined) { | |
response.sendStatus(304); | |
console.log('caaaaaa maaaaaarche') | |
} else { | |
response.status(404).send('cant find '+ name); | |
} | |
}); | |
app.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