init
This commit is contained in:
commit
7813a44af0
5 changed files with 359 additions and 0 deletions
38
server.js
Normal file
38
server.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
const express = require('express')
|
||||
const path = require('path')
|
||||
const app = express()
|
||||
app.use(express.json())
|
||||
|
||||
app.use(express.static('public'))
|
||||
app.use(express.urlencoded())
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.sendFile(path.resolve('./index.html'))
|
||||
})
|
||||
|
||||
app.get('/graph/:artist/:title', async (req, res) => {
|
||||
const artist = req.params.artist;
|
||||
const title = req.params.title;
|
||||
|
||||
const data = await (await fetch(`https://nporadio2.nl/api/statistics/search/tracks/${artist}`, {})).json();
|
||||
|
||||
const id = data.find(it => it.title == title).id
|
||||
|
||||
const standings = await (await fetch(`https://nporadio2.nl/api/statistics/positions/track/${id}`, {})).json();
|
||||
|
||||
res.send(standings);
|
||||
})
|
||||
|
||||
app.get('/trivia/:artist', async (req, res) => {
|
||||
const artist = req.params.artist;
|
||||
|
||||
const data = await (await fetch(`https://nporadio2.nl/api/statistics/search/tracks/${artist}`, {})).json();
|
||||
|
||||
console.log(data);
|
||||
res.send(data);
|
||||
})
|
||||
|
||||
|
||||
app.listen(3000, () => {
|
||||
console.log("Listening on port 3000")
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue