INNER CODE UNIT · Python

index

kingname/SourceCodeofMongoRedis · chapter_12/QASystem/main.py:18

def index(page=0):
    page = int(page)
    session_data = redis.fetch_session(request.cookies.get('session'))
    if page <= 0:
        start = 0
    else:
        start = (page - 1) * 3
    question_id_score_list = redis.get_doc_rank_range('question', start, 2)
    question_list, total_question = mongo.query_question(question_id_score_list)
    total_page = total_question // 3 + (1 if total_question % 3 > 0 else 0)
    page_list = [x for x in range(total_page)]
    return render_template('index.html',
                           question_list=question_list,
                           session=session_data,
                           current_page=page,
                           page_list=page_list)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…