Skip to content

Instantly share code, notes, and snippets.

@Jeremy-san
Last active May 20, 2019 20:06
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/e9c3690a8b68e34c7b19d961f8fcbb5b to your computer and use it in GitHub Desktop.
Save Jeremy-san/e9c3690a8b68e34c7b19d961f8fcbb5b to your computer and use it in GitHub Desktop.
index
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (request, response) => {
response.send('Bienvenue sur Express');
});
app.get('/api/movies', (req, res ) => {
res.send("Récupération de tous les films");
});
app.get('/api/movies/:id', (req, res) => {
const id = req.params.id;
res.json({ result: 'Valide' + id});
});
app.get('/api/employee', (req, res) => {
const name = req.query.name;
if ( name) {
res.status(404).send('Impossible de récupérer ' + name);
} else {
res.status(304);
}
});
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