article pagination
This commit is contained in:
@@ -21,13 +21,21 @@ import controller
|
|||||||
@article_pages.route(".json")
|
@article_pages.route(".json")
|
||||||
def index():
|
def index():
|
||||||
v=request.values
|
v=request.values
|
||||||
if v.has_key("per_page"):
|
try:
|
||||||
pp=int(v["per_page"])
|
if v.has_key("per_page"):
|
||||||
else:
|
pp=int(v["per_page"])
|
||||||
|
else:
|
||||||
|
pp=20
|
||||||
|
if v.has_key("page"):
|
||||||
|
o=(int(v["page"])-1) *pp
|
||||||
|
else:
|
||||||
|
o=0
|
||||||
|
except ValueError:
|
||||||
pp=20
|
pp=20
|
||||||
if v.has_key("page"):
|
o=0
|
||||||
o=(int(v["page"])-1) *pp
|
if not (isinstance(pp,int) and pp>0 and pp<10000):
|
||||||
else:
|
pp=20
|
||||||
|
if not (isinstance(o,int) and o>=0 and o<100000):
|
||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user