Exemplo n.º 1
0
def list_post():
    order_by = request.args.get('order_by', 'recent')
    if order_by == 'recent':
        order_by = 'posted_at desc'
    elif order_by == 'best':
        order_by = 'up desc'
    elif order_by == 'worst':
        order_by = 'down desc'
    elif order_by == 'most':
        order_by = 'visit desc'
    posts = post_service.list(order_by=order_by)
    return map(lambda x: dict(x), posts)
Exemplo n.º 2
0
def most():
    posts = post_service.list(order_by='visit asc')
    return render_template("index.html", posts=posts)
Exemplo n.º 3
0
def worst():
    posts = post_service.list(order_by='down desc')
    return render_template("index.html", posts=posts)
Exemplo n.º 4
0
def recent():
    posts = post_service.list(order_by='posted_at desc')
    return render_template("index.html", posts=posts)