Forums

Dash layout does not render

I have a newbie question. My dash app works perfectly locally but has a problem in deployment. I do not know how to approach this problem. There is no error in the error logs. It seems like the layouts for each panel is loaded. Only the layout in the index file is rendered. The layouts not rendered are stored in a subfolder named panels. Any suggestions will help. Thanks.

I use an index file to launch my application. Below is the script.

import uuid
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from app import app
from panels import overview, geography, proforma


server = app.server

def serve_layout():
    session_id = str(uuid.uuid4())
    return(
         html.Div(
            [
                html.Div(session_id, id='session-id', style={'display': 'none'}),
                html.Div(
                    className="row header",
                    children=[
                        html.Button(id="menu", children=dcc.Markdown("&#8801")),
                        html.Span(
                            className="app-title",
                            children=[
                                dcc.Markdown("**G01122021**"),
                                html.Span(
                                    id="subtitle",
                                    children=dcc.Markdown("&nbsp porfolio assessment"),
                                    style={"font-size": "1.8rem", "margin-top": "15px"},
                                ),
                            ],
                        ),
                        html.Img(src=app.get_asset_url("logo.png")),
                    ],
                ),
                html.Div(
                    id="tabs",
                    className="row tabs",
                    children=[
                        dcc.Link("Overview", href="/"),
                        dcc.Link("Proforma", href="/"),
                        dcc.Link("Geography", href="/"),
                    ],
                ),
                html.Div(
                    id="mobile_tabs",
                    className="row tabs",
                    style={"display": "none"},
                    children=[
                        dcc.Link("Overview", href="/"),
                        dcc.Link("Proforma", href="/"),
                        dcc.Link("Geography", href="/"),
                    ],
                ),
                dcc.Store(id='update_trigger', storage_type='session'),
                dcc.Location(id="url", refresh=False),
                html.Div(id="tab_content"),

            ],

            className="row",
            style={"margin": "0%"},
        )
    )



app.layout = serve_layout()


@app.callback(
    [
        Output("tab_content", "children"),
        Output("tabs", "children"),
        Output("mobile_tabs", "children"),
    ],
    [Input("url", "pathname")],
)
def display_page(pathname):
    tabs = [
        dcc.Link("Overview", href="/overview"),
        dcc.Link("Proforma", href="/proforma"),
        dcc.Link("Geography", href="/geography"),
    ]
    if pathname == "/proforma":
        tabs[1] = dcc.Link(
            dcc.Markdown("**&#9632 Proforma**"),
            href="/proforma",
        )
        return proforma.layout, tabs, tabs
    elif pathname == "/geography":
        tabs[2] = dcc.Link(
            dcc.Markdown("**&#9632 Geography**"), href="/geography"
        )
        return geography.layout, tabs, tabs
    tabs[0] = dcc.Link(
        dcc.Markdown("**&#9632 Overview**"), href="/overview"
    )
    return overview.GetLayout(), tabs, tabs


@app.callback(
    Output("mobile_tabs", "style"),
    [Input("menu", "n_clicks")],
    [State("mobile_tabs", "style")],
)
def show_menu(n_clicks, tabs_style):
    if n_clicks:
        if tabs_style["display"] == "none":
            tabs_style["display"] = "flex"
        else:
            tabs_style["display"] = "none"
    return tabs_style


if __name__ == "__main__":
    app.run_server(debug=False)

Here's how it looks like.

Hi, actually I see some errors in your logs -- can you double check that?

Thanks for the help. Issue resolved.