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)
def most(): posts = post_service.list(order_by='visit asc') return render_template("index.html", posts=posts)
def worst(): posts = post_service.list(order_by='down desc') return render_template("index.html", posts=posts)
def recent(): posts = post_service.list(order_by='posted_at desc') return render_template("index.html", posts=posts)