1 Star 1 Fork 1

张利利/dash_demo_001

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.py 2.41 KB
一键复制 编辑 原始数据 按行查看 历史
zll 提交于 2022-09-27 15:49 . init
from dash import html, dcc, Input, Output
import dash_bootstrap_components as dbc
from views.home import home_page
from views.dash_base import dash_base_html
from views.dash_bootstrap_layout import dash_bootstrap_layout_html
from views.dash_bootstrap_basic import dash_bootstrap_basic_html
from views.checklist import checklist
from server import app
# 左侧侧边栏
left_sidebar = html.Div(
[
html.H2(children='Dash基础', className='display-5'),
html.Hr(),
dbc.Nav(
children=[
dbc.NavLink('Dash介绍', href='/', active="exact"),
dbc.NavLink('Dash基本概念', href='/dash_base', active="exact"),
dbc.NavLink('dash_bootstrap布局', href='/dash_bootstrap_layout', active="exact"),
dbc.NavLink('dash_bootstrap控件', href='/dash_bootstrap_basic', active="exact"),
dbc.NavLink('cards示例', href='/cards', active="exact"),
dbc.NavLink('checklist示例', href='/checklist', active="exact"),
],
vertical=True,
pills=True
),
],
style={"background-color": "rgb(245,245,245)"},
)
# 右侧页面区域
right_content = html.Div(
[
html.Br(),
html.Div(id='right-page-content'),
]
)
# 整体布局
app.layout = html.Div(
[
dcc.Location(id='url'),
dbc.Container(
[
dbc.Row(
[
dbc.Col(left_sidebar, width=2),
dbc.Col(right_content, width=10),
]
),
],
fluid=True,
),
]
)
@app.callback(Output('right-page-content', 'children'), [Input('url', 'pathname')])
def render_page_content(pathname):
if pathname == '/':
return home_page
elif pathname == '/dash_base':
return dash_base_html
elif pathname == '/dash_bootstrap_layout':
return dash_bootstrap_layout_html
elif pathname == '/dash_bootstrap_basic':
return dash_bootstrap_basic_html
elif pathname == '/checklist':
return checklist
return html.Div(
children=[
html.H1("404: Not found", className="text-danger"),
html.Hr(),
html.P(f"The pathname {pathname} was not recognised..."),
],
className='p-3 bg-light rounded-3'
)
if __name__ == '__main__':
app.run_server(port=8050, debug=True)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ll.zhangll/dash_demo_001.git
git@gitee.com:ll.zhangll/dash_demo_001.git
ll.zhangll
dash_demo_001
dash_demo_001
master

搜索帮助