mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
add pagination with default code format
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user