Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. const express = require('express');
  2. const app = express();
  3. const port = 3000;
  4. const movie = "Juno"
  5.  
  6. app.get('/', (request, response) => {
  7. response.send('Welcome to Express');
  8. });
  9. app.get('/api/movies', (request, response) => {
  10. response.send(`Tonight at 19:30 this is the movie I am playing: ${movie}`);
  11. });
  12. app.get('/api/movies/:title', (request, response) => {
  13. response.json({id: request.params.title});
  14. });
  15. app.get('/api/employee', (request, response) => {
  16. //The 304 status gets cancelled but 200 + 200 = 304
  17. response.status(200).send('There are people that work here');
  18. response.status(200).send('There are people that work here');
  19. });
  20. app.get('/api/employees', (request, response) => {
  21. const name = request.query.name;
  22. response.status(404).send(`There is nobody working here called: ${name}`);
  23. });
  24. app.listen(port, (err) => {
  25. if (err) {
  26. throw new Error('Something bad happened...');
  27. }
  28.  
  29. console.log(`Server is listening on ${port}`);
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement