问题描述
我有一个获取随机字符串的函数,然后我有一个@get 请求来获取随机字符串作为请求,但是,结果比我想象的要难。我怎样才能做到这一点?
这是代码片段
link_id = ''
def confirm_email(email,name):
global link_id
letters = string.ascii_lowercase
link_id = ''.join(random.choice(letters) for i in range(100))
@get('/' + link_id)
def lnkoconfirm():
global name
global email
global password
解决方法
您可以使用动态路由。
https://bottlepy.org/docs/dev/tutorial.html#request-routing
@get('/<link_id>')
def lnkoconfirm(link_id):
global name
global email
global password