add pagination with default code format

This commit is contained in:
fadingNA
2024-11-06 22:20:25 -05:00
parent d68e731ffd
commit 101935ae46

View File

@@ -435,6 +435,8 @@ class CombinedJson(Resource):
user = "local"
sort_field = request.args.get('sort', 'date') # Default to 'date'
sort_order = request.args.get('order', "desc") # Default to 'desc'
page = request.args.get('page', 1) # Default to 1
rows_per_page = request.args.get('rows', 10) # Default to 10
data = [
{
"name": "default",
@@ -485,10 +487,15 @@ class CombinedJson(Resource):
"retriever": "brave_search",
}
)
first_index = (int(page_number) - 1) * int(rows_per_page)
last_index = first_index + int(rows_per_page)
paginated_docs = data[first_index:last_index]
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
return make_response(jsonify(data), 200)
return make_response(jsonify(paginated_docs), 200)
@user_ns.route("/api/docs_check")