-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
50 lines (41 loc) · 1.01 KB
/
server.js
File metadata and controls
50 lines (41 loc) · 1.01 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const express = require('express');
const fetch = require('node-fetch');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.set('view engine', 'hbs');
app.use('/static', express.static('static'));
const storage = {
categories :
['blogtalkradio',
'comedy',
'games-hobbies',
'music',
'occult',
'performing-arts', //pop culture
'philosophy',
'technology',
'tv-film' ,
'ubuntu'],
};
app.get('/', function(req,res) {
res.render('index');
})
app.get('/test', function(req,res){
fetch('https://gpodder.net/toplist/5.json')
.then(function(response){
return response.json();
}).then(function(jsonData){
let podcastData = jsonData;
res.render('test', podcastData);
}).catch(function(error){
res.status(500).json({error: 'Failed to get data'});
});
})
app.listen(process.env.PORT || 5000, function(){
console.log('I am listening on port 5000');
});
//
// app.listen(8080, function(){
// console.log('I am listening on port 8080');
// });