correct pagination headers

This commit is contained in:
Andreas Stephanides
2017-01-22 10:06:13 +01:00
parent 6e3247c66a
commit e5bccfe7da
2 changed files with 6 additions and 3 deletions

View File

@@ -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()

View File

@@ -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'])