Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //import the express app
- const express = require('express');
- //create the express application
- const app = express();
- const music = [
- {
- id: 1,
- title: 'Maps',
- Writer: 'Adam Levine Ryan Tedder Benjamin Levin Ammar Malik Noel Zancanella',
- Producer: 'Benny Blanco Tedder Zancanella Noah Passovoy',
- Length: '3:10'
- },
- {
- id: 2,
- title: 'Animals',
- Writer: 'Adam Levine Ryan Tedder Benjamin Levin Ammar Malik Noel Zancanella',
- Producer: 'Benny Blanco Tedder Zancanella Noah Passovoy',
- Length: '3:10'
- },
- {
- id: 3,
- title: 'It Was Always You',
- Writer: 'Levine Sam Martin Jason Evigan Marcus Lomax Jordan Johnson Stefan Johnson',
- Producer: 'Evigan The Monsters and Strangerz S. Johnson',
- Length: '4:00'
- }
- ];
- //set the root route
- app.get('/', (req, res) => {
- return res.send('Hello World!!');
- });
- app.get('/random', (req, res) => {
- // Math.random() * (max - min) + min;
- return res.json(Math.random() * (10 - 0) + 0);
- });
- app.get('/music', (req, res) => {
- return res.json(music);
- });
- //listen the express app to port 3000
- app.listen('3000',() => {
- console.log('Application is running on PORT 3000');
- });
Add Comment
Please, Sign In to add comment