python - flask-debugtoolbar 不显示

标签 python flask

为了更好的调试,我安装了 flask-debugtoolbar。

按照说明进行操作 here .我还重新启动了服务器,希望一切正常。

这是我的代码。

__init__.py

from flask import Flask
from flask.ext.mail import Mail
from flask_debugtoolbar import DebugToolbarExtension

app = Flask(__name__, static_url_path='')
toolbar = DebugToolbarExtension(app)

最佳答案

正如您链接到的文档中明确指出的那样,您必须在您的应用中启用 Debug模式。

The toolbar will automatically be injected into HTML responses when debug mode is on. In production, setting app.debug = False will disable the toolbar.

您还需要指定一个 SECRET_KEY 以启用 flask session cookie。

from flask import Flask
from flask.ext.mail import Mail
from flask_debugtoolbar import DebugToolbarExtension

app = Flask(__name__, static_url_path='')

# Ensure that debug mode is *on*
app.debug = True

# Enable flask session cookies
app.config['SECRET_KEY'] = 'key'

toolbar = DebugToolbarExtension(app)

关于python - flask-debugtoolbar 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36557349/

相关文章:

python - 使自定义记录器可跨多个模块使用

python - Pandas 加入/合并 'Reindexing only valid with uniquely valued Index '

python - pandas int 和 np.int64 中的奇怪 isinstance 行为

python - SQLAlchemy:为具有循环关系的模型类编写单元测试

python - pymongo.errors.ConfigurationError : The "dnspython" module must be installed to use mongodb+srv://URIs even after pymongo and dnspython installed

python - 使用 Flask ping 远程 PC,导致服务器阻塞

python - 如果 file1 的第一列与 file2 中的任何字符串匹配,则将其替换为 file1 的第二列

python - greycomatrix scikit-image python 中的级别参数

python - 重定向到同一页面后,Flask Flash 消息不显示

python - 由于 Flask-WTF 的 CSRF 保护,Flask-Restful POST 失败