SHARE
TWEET

Untitled

a guest May 24th, 2019 54 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 = 4200;
  4.  
  5. app.get('/', (request, response) => {
  6.     response.send('Bienvenue sur Express');
  7. });
  8.  
  9. app.get('/api/movies', (request, response) => {
  10.     response.send('Recuperation de tous les films');
  11. });
  12.  
  13. app.get('/api/movies/:movieId', (request, response) => {
  14.     const movieId = request.params.movieId
  15.     response.json({result : `id: ${movieId}`})
  16. });
  17.  
  18.  
  19.  
  20. app.get('/api/employee', (request, response) => {
  21.     const name = request.query.name
  22.     if (name) {
  23.     response.status(404).send(`Impossible de recuperer l'employe ${name}`);
  24.     }
  25.     else if (!name) {
  26.     response.sendStatus(304)
  27.     }
  28. });
  29.  
  30. app.listen(port, (err) => {
  31.     if (err) {
  32.         throw new Error('Something bad happened...');
  33.     }
  34.  
  35.     console.log(`Server is listening on ${port}`);
  36. });
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
 
Top