Update variable on page load

so here is a simple web app I deployed recently: https://covid19-visualisation-seb.herokuapp.com/

I used the Dash framework and deployed it using Heroku.

I use df = pd.read_csv('owid-covid-data.csv') to load the data set. The latest data set can be found here:


The data is being updated every day. The problem is that if I only set df variable to the link, it’s only going to get the data from the source once when the server starts. So if I wanted to keep the data up to date every day I would have to restart the server every day, which is nonsense.

Dash documentation provides Update on Page Load feature, which looks like this:

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__':

it works when I refresh the page (time updates itself)

but I’d like to reassign a variable on page load, not sure how to do it?