From 6aba3820529934dc8ab0321c9dc4e5fb82f2179e Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sat, 21 Jan 2017 22:08:05 +0100 Subject: [PATCH] article pagination --- articles/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/articles/views.py b/articles/views.py index 923549f..182d0d6 100644 --- a/articles/views.py +++ b/articles/views.py @@ -20,7 +20,16 @@ import controller @article_pages.route("") @article_pages.route(".json") def index(): - articles=controller.get_all(20,0) + v=request.values + if v.has_key("per_page"): + pp=v["per_page"] + else: + pp=20 + if v.has_key(:page): + o=(page-1) *pp + else: + o=0 + articles=controller.get_all_page(pp,o) resp = jsonify(articles=articles) resp.headers['Pagination-Limit']=20 resp.headers['Pagination-Offset']=10