Forums

Flask Webapp works fine but is not fetching data from api

My Flask Webapp works fine but is not fetching data from API. I have scheduled a task to run the script for fetching the data from the API and it's working (returned 0 code) but the data on the webapp didn't change.

The data is only changing when I'm reloading the webapp (green button). Any idea why this is happening? Thank you in advance.

How is data being loadad into your web app?

Data is loaded via jinja to the HTML template

Is the code that accesses the API inside the view function? If it's not, then it will only be executed once, when the website initially starts up. Code that you want to have executed on every request should be inside the view.

ok ill try that

OK, that's fine but I have limited API key usage. So I would like to schedule the execution of my code. Like every 5 minutes.

In such a case you probably need to add some throttling.