def api_blogs(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.find_number('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, blogs=())
    blogs = yield from Blog.find_all(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, blogs=blogs)
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Blog.find_number('count(id)')
    p = Page(num, page_index)
    if num == 0:
        blogs = []
    else:
        blogs = yield from Blog.find_all(orderBy='created_at desc', limit=(p.offset, p.limit))
    return {
        '__template__': 'blogs.html',
        'page': page,
        'blogs': blogs
    }