use page query param instead of separate API route

This commit is contained in:
Xevion
2020-09-15 07:11:55 -05:00
parent ed65362ec6
commit d23855b678

View File

@@ -98,10 +98,8 @@ def api_character_list():
@current_app.route('/api/character/<character>/')
def api_character_all(character: str):
return jsonify(character_data[character])
@current_app.route('/api/character/<character>/<int:page>/')
def api_character_paged(character: str, page: int):
index: int = (page - 1) * 10
return jsonify(character_data[character][index: index + 10])
if request.args['page']:
index: int = (int(request.args['page']) - 1) * 10
return jsonify(character_data[character][index: index + 10])
else:
return jsonify(character_data[character])