swingmusic/app/api/colors.py
mungai-njoroge 861a854f91 add function to validate albums
+ extract colors in watchdogg
+ rename color db files
2023-07-12 08:56:30 +03:00

17 lines
392 B
Python

from flask import Blueprint
from app.store.albums import AlbumStore as Store
api = Blueprint("colors", __name__, url_prefix="/colors")
@api.route("/album/<albumhash>")
def get_album_color(albumhash: str):
album = Store.get_album_by_hash(albumhash)
msg = {"color": ""}
if album is None or len(album.colors) == 0:
return msg, 404
return {"color": album.colors[0]}