Black Lives Matter. Please consider donating to Black Girls Code today.

Live Updates with mutipage app-

I’ve got a multipage app that isn’t updating upon refresh. I’ve recreated a very basic example. ->

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from test_page import overviewLayout
from app import app

def serve_layout():
    tmpLayout = html.Div([
    dcc.Location(id='url', refresh=False),
    return tmpLayout

app.config.suppress_callback_exceptions= True
app.layout = serve_layout

@app.callback(Output('main-content1', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname=='/':
        return overviewLayout
        return html.H3('COMING SOON')

if __name__ == '__main__':

app = dash.Dash(
server = app.server ->

overviewLayout = [
    html.H1('The time is: ' + str(


try changing overviewLayout to be a function. currently it is a variable which means it’s imported and evaluated when you run python rather than when you load the page and the callback is evalauated.

Ok, thanks. So that worked, but it’s now making load times pretty slow (which is expected). Can you shed a bit of light on what is happening? If I wrap my main layout in a function (the serve_layout() function) it will refresh when I refresh the browser, but is the function actually re-executing? Because it will seemingly still point at old data unless I wrap the overviewLayout into a function as well. Am I understanding that correctly?