mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
add routes for getting recently added items
This commit is contained in:
@@ -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}
|
||||
Reference in New Issue
Block a user