https://dash.plot.ly/live-updates
import datetime
import dash
import dash_html_components as html
def serve_layout():
return html.H1('The time is: ' + str(datetime.datetime.now()))
app.layout = serve_layout
if __name__ == '__main__':
app.run_server(debug=True)
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/apps/app1':
return app1.layout
elif pathname == '/apps/app2':
return app2.layout
else:
return '404'
Error
dash.exceptions.InvalidCallbackReturnValue:
The callback for <Output
page-content.children>
returned a value having type function
which is not JSON serializable.
The value in question is either the only value returned,
or is in the top level of the returned list,
and has string representation
<function serve_layout at 0x000002D972BEAB88>
In general, Dash properties can only be
dash components, strings, dictionaries, numbers, None,
or lists of those.