This commit is contained in:
Alfie King 2024-09-01 19:36:21 +01:00
parent 14ee7ef987
commit 4173bc65fd
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,4 @@
python-dotenv
flask
requests
flask-cors

View File

@ -1,9 +1,12 @@
from flask import Flask, request, jsonify, render_template
import requests, os, dotenv, json, base64, time
from flask import Flask, request, jsonify
import requests, os, dotenv, json, base64
from flask_cors import CORS, cross_origin
# Initialize Flask app
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
if os.path.exists('.env'):
dotenv.load_dotenv('.env')
@ -69,6 +72,7 @@ def auth():
return "Authenticated"
@app.route('/api/nowplaying', methods=['GET'])
@cross_origin()
def nowplaying():
cache = get_cache()
data = requests.get('https://api.spotify.com/v1/me/player/currently-playing', headers={