Flask学习系列补充1——debug模式的开启与关闭
如果项目是在pycharm中直接新建的Flask项目(如下图),则使用下面的方法是开启不了debug模式的
if __name__ == '__main__':
theapp.run(debug=False)
需要在pycharm中设置,具体方法如下图
点击Apply,再次启动启动文件,显然debug模式已开启
如果是自己手动创建的文件夹,然后配置项目的虚拟环境,则使用如下的两种方式都是可以开启debug模式的
一种是直接设置
from app import create_app
theapp = create_app()
if __name__ == '__main__':
theapp.run(debug=False)
另一种是读取配置文件的相关设置
from app import create_app
theapp = create_app()
if __name__ == '__main__':
theapp.run(debug=theapp.config['DEBUG'])