Guest User

Untitled

a guest
Nov 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. //import the express app
  2. const express = require('express');
  3.  
  4. //create the express application
  5. const app = express();
  6.  
  7. const music = [
  8. {
  9. id: 1,
  10. title: 'Maps',
  11. Writer: 'Adam Levine Ryan Tedder Benjamin Levin Ammar Malik Noel Zancanella',
  12. Producer: 'Benny Blanco Tedder Zancanella Noah Passovoy',
  13. Length: '3:10'
  14. },
  15. {
  16. id: 2,
  17. title: 'Animals',
  18. Writer: 'Adam Levine Ryan Tedder Benjamin Levin Ammar Malik Noel Zancanella',
  19. Producer: 'Benny Blanco Tedder Zancanella Noah Passovoy',
  20. Length: '3:10'
  21. },
  22. {
  23. id: 3,
  24. title: 'It Was Always You',
  25. Writer: 'Levine Sam Martin Jason Evigan Marcus Lomax Jordan Johnson Stefan Johnson',
  26. Producer: 'Evigan The Monsters and Strangerz S. Johnson',
  27. Length: '4:00'
  28. }
  29. ];
  30.  
  31.  
  32. //set the root route
  33. app.get('/', (req, res) => {
  34. return res.send('Hello World!!');
  35. });
  36.  
  37. app.get('/random', (req, res) => {
  38. // Math.random() * (max - min) + min;
  39. return res.json(Math.random() * (10 - 0) + 0);
  40. });
  41.  
  42. app.get('/music', (req, res) => {
  43. return res.json(music);
  44. });
  45.  
  46. //listen the express app to port 3000
  47. app.listen('3000',() => {
  48. console.log('Application is running on PORT 3000');
  49. });
Add Comment
Please, Sign In to add comment