Track | +Artist | |
---|---|---|
{{ i+1 }} | -{{ queue[i].track }} | -{{ queue[i].artist }} | +
{{ queue[i].track }} | +{{ queue[i].artist }} |
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc7c9cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +.env +.cache diff --git a/app.py b/app.py index 5d65c49..fa42e6f 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,18 @@ -from flask import Flask, render_template, request, redirect, url_for, jsonify +from flask import Flask, render_template, request, jsonify from spotipy import Spotify from spotipy.oauth2 import SpotifyOAuth +from dotenv import load_dotenv +import os + +# Load environment variables from .env file +load_dotenv() # Flask app app = Flask(__name__) -# Spotify API credentials -CLIENT_ID = "f7f2841e0c26492681499a53b4eca29f" -CLIENT_SECRET = "8e1a973438214682939b175bb9f1ed1d" +# Spotify API credentials from environment variables +CLIENT_ID = os.getenv("CLIENT_ID") +CLIENT_SECRET = os.getenv("CLIENT_SECRET") REDIRECT_URI = "http://localhost:80/callback" SCOPE = "user-modify-playback-state user-read-playback-state" @@ -23,6 +28,7 @@ sp = Spotify(auth_manager=SpotifyOAuth( @app.route("/") def home(): return render_template("index.html") + @app.route("/add", methods=["GET"]) def add_song(): @@ -58,7 +64,7 @@ def queue_table(): queue.append({"track": track_name, "artist": artist_name}) current = None if queue_data["currently_playing"]: - current = {"track":queue_data["currently_playing"]["name"], "artist":queue_data["currently_playing"]["artists"][0]["name"]} + current = {"track": queue_data["currently_playing"]["name"], "artist": queue_data["currently_playing"]["artists"][0]["name"]} return render_template("queue_table.html", queue=queue, length=len(queue), now_playing=current) # Run the Flask app diff --git a/requirements.txt b/requirements.txt index 4244895..b214db3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask spotipy +python-dotenv \ No newline at end of file diff --git a/run.bat b/run.bat index f273830..316a7cb 100644 --- a/run.bat +++ b/run.bat @@ -1 +1 @@ -python app.py \ No newline at end of file +cmd /K python -m app \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index fed1883..9fcb5bf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,6 +1,10 @@
+Now Playing:
+ + + + diff --git a/templates/queue_table.html b/templates/queue_table.html index fd4e40b..2f377cf 100644 --- a/templates/queue_table.html +++ b/templates/queue_table.html @@ -1,63 +1,32 @@ - - - - - - - + + + + + + + +# | -Track | -Artist | +
---|