Advertisement
Guest User

Untitled

a guest
May 24th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. const express = require('express');
  2. const app = express();
  3. const port = 3000;
  4. let a = ['/api/employee/', '/api/employee'];
  5.  
  6. app.get('/api/movies', (request, response) => {
  7. response.send('Récupération de tous les films.');
  8. });
  9.  
  10. app.get('/api/movies/:id', (request, response) => {
  11. response.json({ id: request.params.id });
  12. });
  13.  
  14. app.get(a, (request, response) => {
  15. if (request.query.name) {
  16. response.status(404).send("Impossible de récupérer l'employé " + request.query.name + ".");
  17.  
  18. } else {
  19. response.status(304);
  20. }
  21. });
  22.  
  23. app.listen(port, (err) => {
  24. if (err) {
  25. throw new Error('Something bad happened...');
  26. }
  27. console.log(`Server is listening on ${port}`);
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement