mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
break down the api blueprint into smaller blueprints
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from flask import Blueprint, send_file
|
||||
|
||||
from app import instances
|
||||
|
||||
track_bp = Blueprint("track", __name__, url_prefix="/")
|
||||
|
||||
|
||||
@track_bp.route("/file/<trackid>")
|
||||
def send_track_file(trackid):
|
||||
"""
|
||||
Returns an audio file that matches the passed id to the client.
|
||||
"""
|
||||
try:
|
||||
filepath = instances.songs_instance.get_song_by_id(trackid)["filepath"]
|
||||
return send_file(filepath, mimetype="audio/mp3")
|
||||
except FileNotFoundError:
|
||||
return "File not found", 404
|
||||
|
||||
|
||||
@track_bp.route("/sample")
|
||||
def get_sample_track():
|
||||
"""
|
||||
Returns a sample track object.
|
||||
"""
|
||||
|
||||
return instances.songs_instance.get_song_by_album("Legends Never Die", "Juice WRLD")
|
||||
Reference in New Issue
Block a user