def list_all(): try: blog_posts = BlogPost.get_all() print('Total: ', len(blog_posts)) for blog in blog_posts: print(blog_posts.index(blog)) blog.print() except: print('Error when list all files!\n') raise
def delete_post(blog_id=''): if blog_id == '': blog_posts = BlogPost.get_all() last_blog = blog_posts[0] blog_id = last_blog.blog_id try: print('id: ', blog_id) BlogPost.delete_by_id(blog_id) except: print("Error when deleting!") return
def index(page='1'): all_blog_posts = BlogPost.get_all() current_page_info = Page_Info.create(page, all_blog_posts) template = TEMPLATE_ENV.get_template('home.html') return template.render(post_list=current_page_info.data, page_info=current_page_info)