Guest User

Untitled

a guest
Nov 15th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. const express = require('express')
  2. const app = express()
  3. const port = 3000
  4.  
  5. app.get('/', (req, res) => {
  6. res.send('Bienvenue sur Express');
  7. });
  8.  
  9. app.get('/api/movies/:id', function (req, res) {
  10. const id = req.params.id;
  11. var data = {
  12. "id": id
  13. };
  14. res.send(data);
  15. });
  16.  
  17. app.get('/api/employee', (req, res) => {
  18. const url = req.url
  19. if (url === '/api/employee') {
  20. res.sendStatus(304);
  21. } else
  22. res.status(404).send('ERROR 404');
  23. });
  24.  
  25. app.listen(port, (err) => {
  26. if (err) {
  27. throw new Error('Something bad happened...');
  28. }
  29.  
  30. console.log(`Server is listening on ${port}`);
  31. });
Add Comment
Please, Sign In to add comment