Python全系列 教程
3567个小节阅读:5931.3k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
在代码中制作一个错误
xxxxxxxxxx
@app.route('/')
def hello_world():
a = 1
b = 0
c = a/b
return 'Hello World!'
if __name__ == '__main__':
app.run()
启动并访问
控制台倒是给出了错误提示信息,但是我们希望在浏览器也能有相应的提示信息
xxxxxxxxxx
app.run(debug = True)
app.deubg
参数设置xxxxxxxxxx
app.debug = True
app.run()
config
xxxxxxxxxx
app.config.update(DEBUG=True)
# app.config['DEBUG'] = True
app.run()
xxxxxxxxxx
app.config.from_mapping({'DEBUG':True})
app.run()
config
xxxxxxxxxx
class Config:
DEBUG = True
app.config.from_object(config)
app.run()
config
config.py
xxxxxxxxxx
DEBUG = True
config.json
xxxxxxxxxx
{"DEBUG":"True"}
app.py
xxxxxxxxxx
app.config.from_pyfile('config.py')
app.config.from_json('config.json')
通过环境变量
xxxxxxxxxx
DEBUG = True
xxxxxxxxxx
app.config.from_envvar('DEBUG')
实时学习反馈
1. 下面哪个能开启Flask调试模式:
A app.run(debug = true)
B app.run(debug = True)
C app.debug = 'True'
D app.debug = true
答案
1=>D