Hi
I have set-up a dash multi-app server and I have a bunch of analytics pages that do a lot of heavy lifting when they are run.
Problem I have is that when I start a server all the pages seems to be loading or atleast running and doing the calcs before the server is up and running fully.
How can I avoid that and only have the page fully run when its called? My app initialization code is as below
Any help would be appreciated. And apologies in advance if this has been asked/answered somewhere already.
import dash
from dash import dcc
from dash import html, page_registry
import dash_bootstrap_components as dbc
# To use Font Awesome Icons
FA621 = "https://use.fontawesome.com/releases/v6.2.1/css/all.css"
APP_TITLE = "First Dash App"
app = dash.Dash(
__name__,
suppress_callback_exceptions=True,
external_stylesheets=[
dbc.themes.SPACELAB, # Dash Themes CSS
FA621, # Font Awesome Icons CSS
],
title=APP_TITLE,
use_pages=True, # New in Dash 2.7 - Allows us to register pages
)
NAVBAR = create_navbar()
# To use Font Awesome Icons
FA621 = "https://use.fontawesome.com/releases/v6.2.1/css/all.css"
APP_TITLE = "My Analytic Pages"
sidebar = dbc.NavbarSimple(
[dbc.NavLink(pg['title'], href=pg['path']) for pg in dash.page_registry.values()]
)
app.layout = html.Div([sidebar, dcc.Loading(dash.page_container)])
server = app.server
def create_navbar():
navbar = dbc.NavbarSimple(
children=[ # Add as many menu items as you need
dbc.DropdownMenu(
[
dbc.DropdownMenuItem(page["name"], href=page["path"])
for page in page_registry.values()
],
nav=True,
label="Menu",
),
],
# ),
# ],
brand='Home',
brand_href="/",
color="dark",
dark=True,
)
return navbar
if __name__ == '__main__':
app.run_server(debug=False)