From e23f2a6489860d0eff8b917437bf59f7968b967d Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Sun, 19 Mar 2023 23:37:01 +0300 Subject: [PATCH] add route to fetch album color --- app/api/__init__.py | 3 ++- app/api/colors.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 app/api/colors.py diff --git a/app/api/__init__.py b/app/api/__init__.py index b8291fd..230afe8 100644 --- a/app/api/__init__.py +++ b/app/api/__init__.py @@ -6,7 +6,7 @@ from flask import Flask from flask_cors import CORS from app.api import (album, artist, favorites, folder, imgserver, playlist, - search, settings, track) + search, settings, track, colors) def create_api(): @@ -26,5 +26,6 @@ def create_api(): app.register_blueprint(favorites.api) app.register_blueprint(imgserver.api) app.register_blueprint(settings.api) + app.register_blueprint(colors.api) return app diff --git a/app/api/colors.py b/app/api/colors.py new file mode 100644 index 0000000..20826ad --- /dev/null +++ b/app/api/colors.py @@ -0,0 +1,13 @@ +from flask import Blueprint +from app.db.store import Store + +api = Blueprint("colors", __name__, url_prefix="/colors") + + +@api.route("/album/") +def get_album_color(albumhash: str): + album = Store.get_album_by_hash(albumhash) + + return { + "color": album.colors[0] + }