您的位置:首页 > 其它

1.5.4 查询值

2016-01-11 11:43 351 查看
查询字符串(例如/forum?id=1&page=5)在传送小的数字或是键值对时服务器经常用到。你可以使用BaseRequest.query来查询属性(一个FormsDict)来接收这些值,另外BaseRequest.query_string属性用来得到整个字符串。

from bottle import route, request, response, template
@route('/forum')
def display_forum():
forum_id = request.query.id
page = request.query.page or '1'
return template('Forum ID: {{id}} (page {{page}})', id=forum_id, page=page)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bottle框架