Python 烧瓶:绘图:错误:模块';指数';没有属性';app.server'; 上下文
我正在使用Visual Studio代码(VSCode)调试应用程序Python 烧瓶:绘图:错误:模块';指数';没有属性';app.server'; 上下文,python,visual-studio-code,plotly-dash,vscode-debugger,Python,Visual Studio Code,Plotly Dash,Vscode Debugger,我正在使用Visual Studio代码(VSCode)调试应用程序 应用程序主要依赖于,以及 断点未命中! 当我使用launch.json时,断点没有命中(请参见[1]) 我可以使用这个launch.json(参见[2])进行调试,但调试器不会在断点处停止 我希望VSCode在必要时停止在断点上 **launch.json命中断点的正确配置是什么** 谢谢你花时间帮助我 项目的层次结构 launch.json index.py见[4] app.py见[3] 页数 index.py
- 应用程序主要依赖于,以及
- 当我使用launch.json时,断点没有命中(请参见[1])
- 我可以使用这个launch.json(参见[2])进行调试,但调试器不会在断点处停止
- launch.json
- index.py见[4]
- app.py见[3]
- 页数
- index.py
- 事务处理.py
- 下面介绍launch.json[1]
- “烧瓶应用程序”:“index:APP.server”生成此错误错误:未从“index:APP”获取有效的烧瓶应用程序。
- “烧瓶应用程序”:“index.py”生成此错误错误:未能在模块“index”中找到烧瓶应用程序或工厂。使用“FLASK_APP=index:name”指定一个名称。
gunicorn--bind=0.0.0.0--timeout 600索引:app.server
您的[1]示例不起作用,因为您将
FLASK\u APP
设置为index:APP.server
,它尝试在index
模块上查找名为APP.server
的属性。属性名称不能有点(您可以通过导入该模块并尝试getattr(index,“APP.server”)
来验证这一点)。你应该能够制作FLASK\u应用程序
,只需说索引
,它就可以工作了
有关更多详细信息,请参阅
{
"version": "0.2.0",
"configurations": [
{
"name": "Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "index:app.server",
"FLASK_ENV": "development",
"FLASK_DEBUG": "1",
"FLASK_RUN_PORT": "8052"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}\\index.py",
"console": "integratedTerminal"
}
]
}
# -*- coding: utf-8 -*-
import dash
app = dash.Dash(
__name__, meta_tags=[{"name": "viewport",
"content": "width=device-width, initial-scale=1"}]
)
server = app.server
app.config.suppress_callback_exceptions = True
# -*- coding: utf-8 -*-
import dash_html_components as html
import dash_core_components as dcc
from webapp import app
from dash.dependencies import Input, Output
from pages import (
transactions, index)
# Describe the layout/ UI of the app
app.layout = html.Div([
dcc.Location(id="url", refresh=False),
html.Div(id="page-content")
])
# Update page
@app.callback(Output("page-content", "children"),
[Input("url", "pathname")])
def display_page(pathname):
if pathname == "/dash/index":
return index.layout
if pathname == "/dash/transactions":
return transactions.layout
else:
return index.layout
if __name__ == "__main__":
app.run_server(debug=True, port=8051)