from flask import Blueprint, request from app import api from app import helpers, cache from app import functions from app.lib import albumslib, trackslib album_bp = Blueprint("album", __name__, url_prefix="") @album_bp.route("/") def say_hi(): """Returns some text for the default route""" return "^ _ ^" @album_bp.route("/albums") def get_albums(): """returns all the albums""" albums = [] for song in api.DB_TRACKS: al_obj = {"name": song["album"], "artist": song["artists"]} if al_obj not in albums: albums.append(al_obj) return {"albums": albums} @album_bp.route("/album/tracks", methods=["POST"]) def get_album_tracks(): """Returns all the tracks in the given album.""" data = request.get_json() album = data["album"] artist = data["artist"] songs = trackslib.get_album_tracks(album, artist) album = albumslib.find_album(album, artist) return {"songs": songs, "info": album} @album_bp.route("/album/