mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
add routes for getting recently added items
This commit is contained in:
@@ -21,6 +21,7 @@ from app.api import (
|
||||
lyrics,
|
||||
plugins,
|
||||
logger,
|
||||
home,
|
||||
)
|
||||
|
||||
|
||||
@@ -56,4 +57,7 @@ def create_api():
|
||||
# Logger
|
||||
app.register_blueprint(logger.api_bp)
|
||||
|
||||
# Home
|
||||
app.register_blueprint(home.api_bp)
|
||||
|
||||
return app
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
|
||||
from .recents import RecentlyAdded
|
||||
|
||||
api_bp = Blueprint("home", __name__, url_prefix="/home")
|
||||
api = Api(api_bp)
|
||||
|
||||
|
||||
api.add_resource(RecentlyAdded, "/recents/added")
|
||||
@@ -0,0 +1,18 @@
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from app.lib.home.recents import get_recent_items
|
||||
|
||||
parser = reqparse.RequestParser()
|
||||
|
||||
parser.add_argument("limit", type=int, required=False, default=7, location="args")
|
||||
|
||||
|
||||
class RecentlyAdded(Resource):
|
||||
def get(self):
|
||||
cutoff = 14
|
||||
|
||||
args = parser.parse_args()
|
||||
limit = args["limit"]
|
||||
print(limit)
|
||||
|
||||
return {"items": get_recent_items(cutoff)[:limit], "cutoff": cutoff}
|
||||
@@ -1,4 +1,4 @@
|
||||
from flask import Blueprint, request
|
||||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
|
||||
from app.api.logger.tracks import LogTrack
|
||||
|
||||
Reference in New Issue
Block a user