def catalog_page(): try: page = int(request.args.get("page", 1)) posts = PostsService.get_all_posts(limit=2, page=page) count = PostsService.get_count() page_count = math.ceil(count / 2) return render_template("catalog.html", posts=posts, page_count=page_count, int=int) except PostsServiceNotFoundException as error: abort(404)
def index_page(): """ Функция обработчик запросов, получающая запрос и возвращающая html ответ из шаблона (index.html) Для формирования страницы используется сервис PostsService """ posts = PostsService.get_all_posts() categories = CategoriesService.get_all_categories() authors = AuthorsService.get_all_authors() first_posts = posts[:2] posts = posts[2:] return render_template( "index.html", first_posts=first_posts, posts=posts, categories=categories, authors=authors, )
def admin_posts(): posts = PostsService.get_all_posts() return render_template("admin_posts.html", posts=posts)