Skip to content

Instantly share code, notes, and snippets.

@JonesCharly
Created May 17, 2019 10:45
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 JonesCharly/13083e28fd3088fd2a841a4fe8fe5d65 to your computer and use it in GitHub Desktop.
Save JonesCharly/13083e28fd3088fd2a841a4fe8fe5d65 to your computer and use it in GitHub Desktop.
Express n*1
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