V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wico77
V2EX  ›  问与答

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

  •  
  •   wico77 · 2015-03-14 23:26:05 +08:00 · 1749 次点击
    这是一个创建于 3394 天前的主题,其中的信息可能已经有所发展或是发生改变。

    @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 条回复    2015-03-14 23:46:51 +08:00
    sujin190
        1
    sujin190  
       2015-03-14 23:46:51 +08:00
    url路由定义不包括查询差数,查询参数通过request取得
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2619 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:01 · PVG 17:01 · LAX 02:01 · JFK 05:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.