我有一个运行Flask的python程序。我注意到一个奇怪的事情,它看起来像是程序正在运行两次,这是我不想要的。在
这是启动程序的文件(运行服务器.py,在根文件夹/):
from myapp import app
if __name__ == "__main__":
print "woho"
app.run(host='0.0.0.0',debug=True)
运行这个程序时,我可以看到终端中有两个“woho”,表示有什么奇怪的东西。在
在/myapp文件夹中我有一个
^{pr2}$然后在我的视图.py(同样在/myapp中)我有以下所有视图:
from myapp import app
from flask import render_template
@app.route('/')
def index():
return render_template('index.html')
这是由于flask/werkzeug的重新加载程序,当您更改代码时,它会自动重新加载。在
因此,如果您不想/不需要debug=False,例如对于“production”。在
How to stop Flask from initialising twice in Debug Mode?
相关问题 更多 >
编程相关推荐