correct pagination headers
This commit is contained in:
@@ -14,3 +14,6 @@ def search(s):
|
|||||||
|
|
||||||
def get_all_page(lim, off):
|
def get_all_page(lim, off):
|
||||||
return Article.query.order_by(Article.published_date.desc()).limit(lim).offset(off).all()
|
return Article.query.order_by(Article.published_date.desc()).limit(lim).offset(off).all()
|
||||||
|
|
||||||
|
def count():
|
||||||
|
return Article.query.count()
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ def index():
|
|||||||
o=0
|
o=0
|
||||||
articles=controller.get_all_page(pp,o)
|
articles=controller.get_all_page(pp,o)
|
||||||
resp = jsonify(articles=articles)
|
resp = jsonify(articles=articles)
|
||||||
resp.headers['Pagination-Limit']=20
|
resp.headers['Pagination-Limit']=pp
|
||||||
resp.headers['Pagination-Offset']=10
|
resp.headers['Pagination-Offset']=o
|
||||||
resp.headers['Pagination-TotalCount']=100
|
resp.headers['Pagination-TotalCount']=controller.count()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@article_pages.route("/<int:id>",methods=['PUT'])
|
@article_pages.route("/<int:id>",methods=['PUT'])
|
||||||
|
|||||||
Reference in New Issue
Block a user