I am building a simple Flask website. I read CSV file through pd.read_csv, analyze it and output the results to a Flask template.
The CSV file is updated everyday. However the results on a website are not changing, until I restart the server.
To give you a little overview,
I am reading CSV file as follows:
data = pd.read_csv('Data.csv',
parse_dates=True,
infer_datetime_format=True,
index_col='Date')
I assigned values and functions to template variable, for example:
# Variable 1
mean = data['BTC'].mean()
# Function 1
def std():
return data['ETH'].std()
# Passing variables to template
return render_template('page.html', mean = mean, std = std())
And I have lots of variables that I pass to a template.
My app_run code snippet is as follows:
if __name__ == '__main__':
host = os.getenv('IP', '0.0.0.0')
port = int(os.getenv('PORT', 5000))
app.debug = True
app.secret_key = 'longlistofweirdcharacters'
app.run(host = host, port = port)
What should I do, if I want changes in Data.csv to reflect on a template without restarting the server?