def get(self): mode = request.args.get("mode") page_size = int(request.args.get("ps", 6)) page = int(request.args.get("p", 0)) if not mode: data = get_posts(page, page_size) elif mode == 'popular': data = get_populars() return {'status': 'OK', 'data': data}
def get_posts(): try: page = int(request.args.get('p', 1)) except ValueError: return abort(400) posts = post.get_posts(page=page) if len(posts.items) == 0: return abort(404) return render_template('posts.html', posts=posts)