diff --git a/backend/src/app.py b/backend/src/app.py
index 2b636c3..1abebfb 100644
--- a/backend/src/app.py
+++ b/backend/src/app.py
@@ -3,7 +3,9 @@ from flask import Flask, Response, jsonify, request
from flask_cors import CORS
from .room import Room
-from .song import init_db
+from .song import Song, init_db
+
+# from .song_fetch import *
dotenv.load_dotenv()
@@ -12,7 +14,18 @@ app = Flask(__name__)
CORS(app)
-ROOMS: dict[int, Room] = {} # { room_id: room, ... }
+ROOMS: dict[int, Room] = {
+ 1234: Room(
+ 1234,
+ (0.0, 1.0),
+ "Test Room",
+ None,
+ {"Rock", "Metal"},
+ {},
+ [],
+ [Song(mbid="test", title="
", artist="", tags=["Metal"], image_id="img-id", youtube_id="yt-id")],
+ )
+} # { room_id: room, ... }
def error(msg: str, status: int = 400) -> Response:
@@ -21,12 +34,7 @@ def error(msg: str, status: int = 400) -> Response:
return res
-@app.route("/api")
-def index():
- return "hello from flask"
-
-
-@app.route("/api/join")
+@app.get("/api/join")
def join():
room_id = request.args.get("room")
code = request.args.get("code")
@@ -43,6 +51,25 @@ def join():
return {"success": True, "ws": f"/ws/{room_id}"}
+@app.get("/api/queue")
+def queue():
+ if (room_id := request.args.get("room")) is None:
+ return error("Missing room id")
+
+ if (room := ROOMS.get(int(room_id))) is None:
+ return error("Invalid room")
+
+ return {"success": True, "queue": room.playing}
+
+
+@app.post("/api/queue/next")
+def queue_next(): ...
+
+
+@app.post("/api/queue/renew")
+def queue_renew(): ...
+
+
init_db()
if __name__ == "__main__":
app.run(debug=True)
diff --git a/backend/src/room.py b/backend/src/room.py
index 51b96e2..e6ebd4b 100644
--- a/backend/src/room.py
+++ b/backend/src/room.py
@@ -21,8 +21,9 @@ class Room:
pin: int | None
tags: set[str]
- songs: dict[str, UserScoredSong]
- history: list[Song]
+ songs: dict[str, UserScoredSong] # canzoni + voto
+ history: list[Song] # canzoni riprodotte (in ordine)
+ playing: list[Song] # canzoni che sono i riproduzione
def rank_song(self, song: Song, user_score: int) -> float:
rank = 0.0