-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
49 lines (40 loc) · 1.13 KB
/
app.py
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
from flask import Flask, jsonify, request
from flask_cors import CORS
import jiosaavn
app = Flask(__name__)
app.secret_key = 'xec97xb2x8fxd9xd8xed}&sxdbxc0x86Vx87&xa5xcb'
CORS(app)
@app.route('/')
def home():
return "API is UP and running"
@app.route('/song')
def song():
query = request.args.get('query')
if query:
return jsonify(jiosaavn.search_for_song(query))
else:
error = {
'success': False,
'message': 'You need to enter a query',
'data': [],
}
return jsonify(error)
@app.route('/playlist')
def playlist():
query = request.args.get('query')
if query:
return jsonify(jiosaavn.search_for_playlist(query))
# try:
# val = int(query)
# return jsonify(jiosaavn.get_playlist(query))
# except Exception:
# return jsonify(jiosaavn.search_for_playlist(query))
else:
error = {
'success': False,
'message': 'You need to enter a query',
'data': [],
}
return jsonify(error)
if __name__ == '__main__':
app.run(debug=True, threaded=True)