def article(): try: pid = request.args['p'] one = article_server.get_by_id(pid) recent_articles = article_server.get_recent() return render_template('index/article.html', title = one.title, one = one, recent_articles = recent_articles) except: return redirect(url_for('main.article_list'))
def article_list(page=0): limit = config.ARTICLE_PER_PAGE query_type = request.args.get('query_type') keyword = request.args.get('keyword') keyword = keyword if keyword else '' sum = article_server.get_count(query_type=query_type, keyword = keyword) try : offset = int(page) * limit tags = article_server.get_all_tags() articles = article_server.get_list(offset, limit, query_type=query_type, keyword = keyword) recent_articles = article_server.get_recent() return render_template('index/article_list.html', title = u'解题报告', articles = articles, tags = tags, recent_articles = recent_articles, page = int(page), sum = sum, limit = limit, query_type = query_type, keyword = keyword) except: return redirect(url_for("main.article_list"))