mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
Finish documentation for all endpoints
+ fix #193 (settings https redirect) + fix open api docs on binary + fix git error on binary + remove flask-restful hopefully, I didn't break something 😩
This commit is contained in:
committed by
Mungai Njoroge
parent
99ec11565c
commit
0af1ae1d8e
@@ -1,11 +1,25 @@
|
||||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
from flask_openapi3 import Tag
|
||||
from flask_openapi3 import APIBlueprint
|
||||
|
||||
from .recents import RecentlyAdded, RecentlyPlayed
|
||||
from app.api.apischemas import GenericLimitSchema
|
||||
from app.lib.home.recentlyadded import get_recent_items
|
||||
from app.lib.home.recentlyplayed import get_recently_played
|
||||
|
||||
api_bp = Blueprint("home", __name__, url_prefix="/home")
|
||||
api = Api(api_bp)
|
||||
bp_tag = Tag(name="Home", description="Homepage items")
|
||||
api = APIBlueprint("home", __name__, url_prefix="/home", abp_tags=[bp_tag])
|
||||
|
||||
|
||||
api.add_resource(RecentlyAdded, "/recents/added")
|
||||
api.add_resource(RecentlyPlayed, "/recents/played")
|
||||
@api.get("/recents/added")
|
||||
def get_recently_added(query: GenericLimitSchema):
|
||||
"""
|
||||
Get recently added
|
||||
"""
|
||||
return {"items": get_recent_items(query.limit)}
|
||||
|
||||
|
||||
@api.get("/recents/played")
|
||||
def get_recent_plays(query: GenericLimitSchema):
|
||||
"""
|
||||
Get recently played
|
||||
"""
|
||||
return {"items": get_recently_played(query.limit)}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from app.lib.home.recentlyadded import get_recent_items
|
||||
from app.lib.home.recentlyplayed import get_recently_played
|
||||
|
||||
parser = reqparse.RequestParser()
|
||||
|
||||
parser.add_argument("limit", type=int, required=False, default=7, location="args")
|
||||
|
||||
|
||||
class RecentlyAdded(Resource):
|
||||
def get(self):
|
||||
args = parser.parse_args()
|
||||
limit = args["limit"]
|
||||
|
||||
return {"items": get_recent_items(limit)}
|
||||
|
||||
|
||||
class RecentlyPlayed(Resource):
|
||||
def get(self):
|
||||
args = parser.parse_args()
|
||||
limit = args["limit"]
|
||||
|
||||
return {"items": get_recently_played(limit)}
|
||||
Reference in New Issue
Block a user