views.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:podofo 作者: VieVie31 项目源码 文件源码
def search_page():
    query = request.args.get('s')
    page  = request.args.get('p')

    if not query:
        return render_template('search.html', allow_upload=app.config['ALLOW_UPLOAD'], count_pdf=count_pdf())

    try:
        page = abs(int(page))
    except:
        page = 0

    query = query.lower()
    query = unicodedata.normalize('NFKD', query).encode('ASCII', 'ignore')
    words = query.split()[:5] #max 5 words for querying...
    words = map(secure_filename, words)
    query = " ".join(words)

    words = map(lemmatize, words)

    if not words:
        return render_template('search.html')

    rows, speed, next_button = get_results(words, page)

    if next_button:
        next_button = page + 1

    return render_template('results.html', user_request=query, rows=rows, speed=speed, next_button=next_button)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号