【发布时间】:2013-05-23 11:46:56
【问题描述】:
在瓶子里,路线是这样的:
@get('/ws/contacts/:uid')
如何向路由添加更多参数,以及如何编写 @get() 代码?
【问题讨论】:
标签: python-2.7 bottle
在瓶子里,路线是这样的:
@get('/ws/contacts/:uid')
如何向路由添加更多参数,以及如何编写 @get() 代码?
【问题讨论】:
标签: python-2.7 bottle
只需使用多个通配符:
@get('/ws/contacts/:uid/:itemid')
def get_user_item(uid, itemid):
return 'you passed in uid={} and itemid={}'.format(uid, itemid)
P.S.,您使用的是已弃用的通配符语法。除非您需要使用旧版本的 Bottle(0.9 或更早版本),否则我建议您使用 modern syntax,如下所示:
@get('/ws/contacts/<uid:int>/<itemid:int>')
【讨论】: