wico77
V2EX  ›  问与答

flask url 里加上?和=就出错怎么回事?

  •  
  •   wico77 · Mar 14, 2015 · 2072 views
    This topic created in 4077 days ago, the information mentioned may be changed or developed.

    @x.route('/index.php?q=<key>')
    @x.route('/search/<key>')
    @x.route('/search/<key>/<int:page>')
    def search_view(key, page=1):
    global keys
    k = key.replace('-',' ')
    dic = dict(
    videos=Video.objects.search_text(k).paginate(page=page, per_page=24),
    page=page,
    key=k,
    title='%s - page %s' % (key, page)
    )
    if key not in keys:
    keys.append(key)
    if len(keys) >= 25:
    keys = keys[-1:-26:-1]

    f = open('search.txt', 'w+')
    for k in keys:
        f.write('%s\n' % k)
    f.close()
    
    g.keys = keys
    return render_template('search.html', **dic)
    

    以上配置访问search/很正常,但访问/index.php?q=就404了。请问问题出在哪里?

    1 replies    2015-03-14 23:46:51 +08:00
    sujin190
        1
    sujin190  
       Mar 14, 2015
    url路由定义不包括查询差数,查询参数通过request取得
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1035 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:32 · PVG 02:32 · LAX 11:32 · JFK 14:32
    ♥ Do have faith in what you're doing.