2013-05-28 14 views
0

在瓶,這樣的路線:多發的論點瓶的路線

@get('/ws/contacts/:uid') 

我怎麼能添加更多的參數的路線,以及如何編寫的@get()?

+0

與路由的例子:http://bottlepy.org/docs/開發/ tutorial.html#教程路由 –

回答

1

只需使用多個通配符:

@get('/ws/contacts/:uid/:itemid') 
def get_user_item(uid, itemid): 
    return 'you passed in uid={} and itemid={}'.format(uid, itemid) 

P.S.,您使用的是過時的通配符語法。除非你需要使用舊版本瓶(0.9或更早),我建議你使用modern syntax,就像這樣:

@get('/ws/contacts/<uid:int>/<itemid:int>')