[英]Syntax error flask application
I have following code: 我有以下代码:
t1 = threading.Thread(target = app.run, args = (host='0.0.0.0', port = 443))
and it gives me an error: 它给了我一个错误:
File "/home/deploy/tgbot/tgbot.py", line 1170
t1 = threading.Thread(target = app.run, args = (host='0.0.0.0', port = 443))
^
What is the problem? 问题是什么?
The sequential arguments for app.run
can be passed in a tuple (constructed with parentheses, but no names). app.run
的顺序参数可以在元组中传递(用括号构造,但没有名称)。 The named arguments must be passed in a dictionary. 命名参数必须在字典中传递。 Dictionaries are constructed with
dict()
or curly braces, not parentheses. 字典使用
dict()
或大括号(而不是括号dict()
构造。
Since host
and port
are the first two arguments to app.run
, any of the following should work: 由于
host
和port
是app.run
的前两个参数,因此以下任何一项都可以工作:
# positional args, passed as a tuple
t1 = threading.Thread(target=app.run, args=('0.0.0.0', 443))
# named args, passed in a dictionary created via dict()
t1 = threading.Thread(target=app.run, kwargs=dict(host='0.0.0.0', port=443))
# named args, passed in a dictionary created via {}
t1 = threading.Thread(target=app.run, kwargs={'host': '0.0.0.0', 'port': 443}))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.