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

Updates on Page Load doesn't work

The second part of this document: 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 = dash.Dash()
app.layout = serve_layout()

if __name__ == '__main__':
    app.run_server()

It can not reload the app.layout every refresh.

It’s supposed to be

app.layout = serve_layout

i.e. it’s supposed to be a function (" If you change this to a function, then a new datetime will get computed everytime you refresh the page.").

So quickly reply.

I’v already got the problem, but the root cause is the Dash version. After upgrading, it works.

Thanks~

BTW, as you are online, can you help with this two questions? Thank you~

Dash is very good tool.

The old version of Dash doesn’t support such

    app.layout = serve_layout

Remember to upgrade it.

In [2]: dash.__version__
Out[2]: '0.26.3'

the above version works

So quickly reply.

I’v already got the problem, but the root cause is the Dash version. After upgrading, it works.

Thanks~

BTW, as you are online, can you help with this two questions? Thank you~

Dash is very good tool.