app.run() 方法是启动一个本地开发服务器,但是你需要在修改代码后手动重启服务器。 这样做并不好,Flask 能做得更好。如果启用了调试支持,在代码修改的时候服务器能够自动加载, 并且如果发生错误,它会提供一个有用的调试器。
有两种方式开启调式模式。一种是在应用对象上设置标志位:
app.debug = True
app.run()
或者作为 run 的一个参数传入:
·```
app.run(debug=True)
两种方法效果是一样的。
当然了,你也可以采用flask run的方式来运行应用,此时你需要配置
```shell
set FLASK_APP=index.py
set FLASK_ENV=development