在这里要做的最简单的事情就是将
use_reloader=False您的呼叫添加到
app.run-即:
app.run(debug=True,use_reloader=False)
或者,您可以检查
WERKZEUG_RUN_MAIN环境中的值:
if os.environ.get("WERKZEUG_RUN_MAIN") == "true": # The reloader has already run - do what you want to do here但是,当您希望行为在加载过程中 以外的 任何时间发生时,情况会更加复杂:
if not app.debug or os.environ.get("WERKZEUG_RUN_MAIN") == "true": # The app is not in debug mode or we are in the reloaded process

![如何阻止Flask在调试模式下进行两次初始化?[重复] 如何阻止Flask在调试模式下进行两次初始化?[重复]](http://www.mshxw.com/aiimages/31/647001.png)
