-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (25 loc) · 823 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Require dependencies
const express = require('express');
// Import our IMDBScraper class
const IMDBScraper = require('./app/IMDBScraper');
// use express
const app = express();
// set our port
const port = process.env.PORT || 3000;
app.set('port', port);
// set url
const otherhoodImdbUrl = 'https://www.imdb.com/title/tt4180560/';
// Create a new instance of our IMDBScraper class
const otherhoodCastScraper = new IMDBScraper(otherhoodImdbUrl);
// set our route to GET all the JSON
app.get('/', (req, res) => {
// render JSON data on localhost:3000
otherhoodCastScraper
.getIMDbJSON()
.then(data => res.json({ name: 'Otherhood', cast: data }))
.catch(err => console.error(err.stack));
});
// Run our server
app.listen(port, () =>
console.log(`Express application running on port ${port}`)
);