예제 #1
0
 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}
예제 #2
0
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)