-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (25 loc) · 733 Bytes
/
app.py
File metadata and controls
32 lines (25 loc) · 733 Bytes
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
from flask import Flask, jsonify, request
import requests
app = Flask(__name__)
@app.route("/")
def index():
title = request.args.get('title', type=str)
data = requests.get(
"http://api.deezer.com/search?q={}".format(title)).json()
track = data["data"][0]
album = track["album"]
title = track["title"]
artist = track["artist"]["name"]
albumName = album["title"]
if "cover_xl" in album:
coverAlbum = album["cover_xl"]
else:
coverAlbum = album["cover_big"]
return jsonify({
"title": title,
"artists": [artist],
"albumName": albumName,
"albumCover": coverAlbum
})
if __name__ == "__main__":
app.run(threaded=True, port=5000)