SHARE
TWEET

Untitled

a guest Mar 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const app = express();
  3. const port = 3000;
  4.  
  5. app.get('/', (request, response) => {
  6.     response.send('Bienvenue sur Express');
  7. });
  8. app.get('/api/movies', (req, res) => {
  9.     res.send('Recuperation de tous les films')
  10. });
  11. app.get('/api/movies/:name', (req, res) => {
  12.     const movieId = req.params.name;
  13.     res.json({ id: movieId });
  14. })
  15. app.get('/api/employee/', (req, res) => {
  16.     const employeesName = req.query.name;
  17.     if (employeesName) {
  18.         res.status(404).send(`Impossible de r√©cuperer l'employ√© ${employeesName}`)
  19.     } else {
  20.         res.sendStatus(304);
  21.     }
  22. })
  23. app.listen(port, (err) => {
  24.     if (err) {
  25.         throw new Error('Something bad happened...');
  26.     }
  27.  
  28.     console.log(`Server is listening on ${port}`);
  29. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top