Crozier Ntwe
Crozier Ntwe

Reputation: 29

How to update data on a webpage using Flask?

I am trying to call a class method which then returns a list such as ['Station: 0', 'Place1: 2', 'Extension12: 4'] and then display this list in flask webpage. My problem is, When the list is updated by the call_agent.Main_Agent() method, to something like this ['Station: 0', 'Place2: 2', 'Extension12: 4'] the webpage does not update the records. I was wondering what could be the problem

Here is my code below:

file_path = '../SAPS_Forecast/Dockets.txt'

app = Flask(__name__)

call_agent = UtilityAgent(file_path)

path_sequence = call_agent.Main_Agent()

@app.route('/forecast.html')
def My_Forecast():
    return render_template('./forecast.html', post=path_sequence)

Upvotes: 0

Views: 657

Answers (1)

Kairav Parekh
Kairav Parekh

Reputation: 55

Even I used to get the same error. What I did was saved the data in an external database like sqlite or MySql and in the route function, I retrieve the data directly from the database. And then after reloading, the web-page updates.

Upvotes: 1

Related Questions