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

[Solved] Live reload on change of HTML

Hi All,

I see you can wrap things in a function, like below if need to have something refresh each time the page is reloaded. This is cool, but what if you just make a change to the HTML (for example, changing ‘The time is’ to ‘The time is now’ ) in the example below - in that case it seems you need to restart the server to see the change taking effect? How are people getting around this?

If you change this to a function, then a new datetime will get computed everytime you refresh the page. Give it a try:
import dash
import dash_html_components as html
import datetime
def serve_layout():
return html.H1('The time is: ’ + str(datetime.datetime.now()))
app.layout = serve_layout
if name == ‘main’:
app.run_server()

Hang on, scratch this question!

just a matter of changing:

if name == ‘main’:
app.run_server()

if name == ‘main’:
app.server.run(debug=True)

Yup, that’s it exactly!