官术网_书友最值得收藏!

The debug mode

The Flask application run method has a debug option, which, when used, runs it in the debug mode:

    app.run(debug=True) 

The debug mode is a special mode, where the built-in debugger takes precedence on any error, and allows you to interact with the app from a browser:

The console in the web-debugger will let you interact with the current app, and inspect variables or execute any Python code that is in the current execution frame.

Flask will even let you configure a third-party debugger. JetBrains's PyCharm (https://www.jetbrains.com/pycharm), for example, is a commercial IDE for Python, which offers a powerful visual debugger that can be set up to run with Flask.

Since the debug mode allows remote code execution, it's a security hazard even though you need to provide a PIN to access the console. In 2015, the Patreon online service got hacked via the Flask debugger. You need to be extremely cautious not to run the debug mode in production. The Bandit security linter ( https://wiki.openstack.org/wiki/Security/Projects/Bandit) tracks Flask applications that are executed with a plain debug flag, and can be used to prevent deploying an application with that flag.

The plain old pdb module is also a good option when you are tracking down a problem by inserting a pdb.set_trace() call in your code.

主站蜘蛛池模板: 柘城县| 珲春市| 驻马店市| 南川市| 新沂市| 安仁县| 德化县| 青神县| 任丘市| 财经| 汾西县| 林芝县| 双鸭山市| 昌乐县| 宁阳县| 色达县| 平南县| 文成县| 宽甸| 绍兴市| 裕民县| 兴国县| 拉孜县| 扬中市| 随州市| 杨浦区| 安阳县| 甘肃省| 满城县| 枣庄市| 合川市| 新兴县| 游戏| 陈巴尔虎旗| 深水埗区| 青海省| 大石桥市| 安龙县| 龙门县| 台南市| 钦州市|