在Flask调试模式下禁用默认/控制台路由的最佳方法是什么? [英] What's the best way to disable the default /console route in Flask debug mode?

查看:222
本文介绍了在Flask调试模式下禁用默认/控制台路由的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的应用程序的仪表板区域被称为/控制台。然而,Flask使用werkzeug.debug.DebuggedApplication( http://werkzeug.pocoo.org/docs/debug/ ),它使用/ console作为默认的调试路径。 Flask本身只有调试标志,

pre $ app.run(debug = True)

没有其他选项可以覆盖该路径。我的选择是什么?



我暂时添加了以下内容,但我宁愿不必这样做,因为我在JS前面有一些复杂的事情发生,结束时,像注册时重定向等。

$ pre $如果app.debug
app.register_blueprint(.., url_prefix ='/ con')
else:
app.register_blueprint(...,url_prefix ='/ console')

在你的 app.run 中设置 use_evalex = False

解决方案调用禁用控制台,但仍然有重新加载和漂亮的Werkzeug不要恐慌调试器:

pre $ if __name__ =='__main__':
app.run(debug = True,use_evalex = False)


I want my application's dashboard area to be called /console. However, Flask uses werkzeug.debug.DebuggedApplication (http://werkzeug.pocoo.org/docs/debug/), which uses /console as the default Debug path. Flask itself only has the debug flag,

app.run(debug=True)

with no other options to override that path. What are my options?

I temporarily added the following, but I'd rather not have to do that because I have some intricate thing's going on in JS on the front-end, like a redirect during registration, etc.

if app.debug:
  app.register_blueprint(.., url_prefix='/con')
else:
  app.register_blueprint(..., url_prefix='/console')

解决方案

Set use_evalex=False in your app.run call to disable the console but still have reloading and the pretty Werkzeug "Don't Panic" debugger:

if __name__ == '__main__':
    app.run(debug=True, use_evalex=False)

这篇关于在Flask调试模式下禁用默认/控制台路由的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆