python - 使用 Bottle 文档中的示例,我仍然得到 query_string 的空值

标签 python bottle

使用 Bottle 内置的 WSGI 服务器,以下是相关的 HTML:

form style="display: inline;" action="/forum?id=2&page=5">
        <input type="submit" value="Forum"/></form>

这是我的应用程序的路线:

@rolodex.route('/forum')
def display_forum():
    forum_id = bottle.request.query.id
    page = bottle.request.query.page or '1'
    return 'Forum ID: %s (page %s)' % (forum_id, page)

以下是点击“论坛”按钮时得到的结果:

论坛 ID:(第 1 页)

关于我可能做错了什么有什么想法吗?这基本上与文档中找到的示例完全相同:

bottlepy.org/docs/0.11/tutorial.html#request-data

最佳答案

也许表单操作中的查询字符串正在与请求交互。当您将 idpage 设置为正确的表单字段时会发生什么?像这样:

<form action="/forum">
    <input type="text" name="id" value="2"/>
    <input type="text" name="page" value="5"/>
    <input type="submit" value="Forum"/>
</form>

(或者,当您直接使用浏览器点击它时?例如,http://yourserver/forum?id=2&page=5)

关于python - 使用 Bottle 文档中的示例,我仍然得到 query_string 的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16245381/

相关文章:

python - 查找位于点云凹包中的点

Python 按两个值对列表进行排序

python - TestCase self.assertEqual 不匹配类似的字符串

python - 我无法理解使用 cherrypy/bottle 的多线程

python-3.x - 使用 Bottle.py 提供嵌套的静态文件

emacs - 将现有的 YAsnippet 模式指向新的文件类型

python - Bottle pandas 返回 xls 文件

python - 如何测试涉及类数据的 python 类中的顺序操作

python - gevent-socketio 与 Python Bottle

python - windows 中的合成器听起来比 linux 中的好得多(python 和 pyttsx3)