[英]Making an @get() request using a variable - bottle.py
I have a function that gets a random string, then I have a @get request to get the random string as a request, however, it turned out to be harder than I thought.我有一个获取随机字符串的 function,然后我有一个 @get 请求来获取随机字符串作为请求,但是,结果比我想象的要难。 How can I make this work?
我怎样才能使这项工作?
here's a snippet of the code这是代码片段
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
You can use dynamic routing.您可以使用动态路由。
https://bottlepy.org/docs/dev/tutorial.html#request-routing https://bottlepy.org/docs/dev/tutorial.html#request-routing
@get('/<link_id>')
def lnkoconfirm(link_id):
global name
global email
global password
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.