使用 VS Code 的开发工具 UI 破折号

问题描述 投票:0回答:1

我正在尝试使用 vscode 调试应用程序,我当前的 vscode 配置是:

            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "${workspaceFolder}\\src\\app.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "1"
            },
            "args": [
                "run"
            ]

我正在通过以下方式运行应用程序:

if __name__ == "__main__":
    app.run_server(debug=True, dev_tools_ui=True)

问题是 dev_tools_ui 没有显示在右下角或任何地方。

有什么想法吗?

python plotly-dash vscode-debugger
1个回答
0
投票

来自官方文档

配置环境变量 所有的 dev_tools 变量都可以 设置环境变量,只需将 dev_tools_ 替换为 dash_ 并转换为大写。这可以让你有不同的运行 无需更改代码即可配置。

Linux/macOS:

export DASH_HOT_RELOAD=false

窗户:

set DASH_DEBUG=true

通过运行这些功能,我们将阻止您使用这些功能 生产中的特点。提醒一下,以下情况不应使用 run 在生产中部署您的应用程序。相反,该应用程序应该是 在服务器上使用gunicorn运行= app.server实例。我们不跑 在生产中使用开发工具是因为:

显示服务器端回溯是一个安全漏洞开发工具 功能会导致性能损失:组件会产生成本 验证并加载更大的开发包。

或者在 Python 中尝试一下:


    dash_app.init_app(flask_app)
    
    if os.getenv("FLASK_ENV", "production") == "development":
        # Ensure that the Flask app is in debug mode
        flask_app.debug = True
        # Enable the Dash Dev Tools
        dash_app.enable_dev_tools(
            # bool, activate all the dev tools listed below.
            debug=True,
            # bool, set to False to explicitly disable dev tools UI in debugger mode (default=True). This UI is the blue button in the bottom right corner that contains the error messages, server status, and the callback graph.
            dev_tools_ui=True,
            # bool, set to False to explicitly disable Component Validation (default=True)
            dev_tools_props_check=True,
            # bool, serve the dev JavaScript bundles from the local filesystem
            dev_tools_serve_dev_bundles=True,
            # bool, set to True to enable hot reloading (default=False)
            dev_tools_hot_reload=True,
            # float, interval in seconds at which the renderer will request the reload hash and update the browser page if it changed. (default=3)
            dev_tools_hot_reload_interval=3.0,
            #  float, delay in seconds between each walk of the assets folder to detect file changes. (default=0.5 seconds)
            dev_tools_hot_reload_watch_interval=0.5,
            # int, number of times the reloader is allowed to fail before stopping and sending an alert. (default=8)
            dev_tools_hot_reload_max_retry=8,
            # bool, remove the routes access logging from the console. (default=True)
            dev_tools_silence_routes_logging=True,
            # bool, simplify tracebacks to just user code, omitting stack frames from Dash and Flask internals. (default=True)
            dev_tools_prune_errors=True,
        )

或者在 VS Code 的“launch.json”中尝试:

 "version": "0.2.0",
  "configurations": [
    {
      "name": "Dash RCOM Only (No Flask Admin)",
      "type": "debugpy",
      "request": "launch",
      // "program": "${file}",
      // "console": "integratedTerminal",
      "module": "flask",
      "env": {
        "FLASK_APP": "wsgi_rcom_only:flask_app",
        // "FLASK_APP": "wsgi_rcom_only:dash_app.server",
        "FLASK_ENV": "development",
        // "FLASK_DEBUG": "0",
        "FLASK_RUN_HOST": "0.0.0.0",
        "FLASK_PORT": "5000",        
        "DASH_DEBUG": "true",
        "DASH_UI": "true",
        "DASH_PROPS_CHECK": "true",
        "DASH_SERVE_DEV_BUNDLES": "true",
        "DASH_HOT_RELOAD": "true",
        "DASH_HOT_RELOAD_INTERVAL": "true",
        "DASH_HOT_RELOAD_WATCH_INTERVAL": "true",
        "DASH_HOT_RELOAD_MAX_RETRY": "true",
        "DASH_SILENCE_ROUTES_LOGGING": "true",
        "DASH_PRUNE_ERRORS": "true",
      },
      "args": [
        "run",
        "--no-debugger",
        "--no-reload",
        // "--with-threads"
        // "--without-threads"
      ],
      "jinja": true,
      "justMyCode": false,
      // "stopOnEntry": true,
    },
}
© www.soinside.com 2019 - 2024. All rights reserved.