引入接口频率限制机制
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from flask import jsonify
|
from flask import jsonify, request
|
||||||
|
|
||||||
|
|
||||||
def success_api(msg: str = "成功"):
|
def success_api(msg: str = "成功"):
|
||||||
@@ -36,6 +36,6 @@ def table_api(msg: str = "", count=0, data=None, limit=10):
|
|||||||
'code': 0,
|
'code': 0,
|
||||||
'data': data,
|
'data': data,
|
||||||
'count': count,
|
'count': count,
|
||||||
'limit': limit
|
'limit': min(request.args.get('limit', default=10, type=int), 90)
|
||||||
}
|
}
|
||||||
return jsonify(res)
|
return jsonify(res)
|
||||||
@@ -64,7 +64,7 @@ class Query(BaseQuery):
|
|||||||
if page is None:
|
if page is None:
|
||||||
page = request.args.get('page', type=int)
|
page = request.args.get('page', type=int)
|
||||||
if limit is None:
|
if limit is None:
|
||||||
limit = request.args.get('limit', type=int)
|
limit = min(request.args.get('limit', default=10, type=int), 90)
|
||||||
|
|
||||||
return self.paginate(page=page,
|
return self.paginate(page=page,
|
||||||
per_page=limit,
|
per_page=limit,
|
||||||
|
|||||||
Reference in New Issue
Block a user