I have this app that collects data from an API (League of Legends) and then displays it on a flask website. It checks if you've played new games since last (the data is stored in a json file) and if so it starts a new function that gathers the new data. Then it's shown on the website collecting the json data that is uploaded by flask:
@app.route('/index_get_data', methods=['GET']) def stuff(): return jsonify(load_matches())
My problem is that it works perfectly on my local "server" (running it from Pycharm) and it works on my pythonanywhere if there are no new matches. I.e. if the load_matches() function never has to call the "gather data" function. It also works if I call the load_matches() function in the code - without having it in a flask route. Something like:
data = load_matches() @app.route('/index_get_data', methods=['GET']) def stuff(): return jsonify(data)
This means that new data is only collected when I reload my web app though - since it's not dynamically connected by flask.
When I use the first method, where load_matches() is called in flask, (the return jsonify(load_matches()) one) I get an error. The error is a part of the code in the "gather data" function. However that code, again, works fine when it's not called in flask. So I don't think that's the issue. ALSO i receive an email telling me that "One or more of your processes have exceeded the RAM limit (currently 3GB), and have been killed. They were: myusername: myusername.eu.pythonanywhere.com uWSGI worker 1".
On my site itself (which won't load because of the error) I get "Error code: 502-backend".
Long story short; why does my app not work when called from flask (when it does on my local server)?
Hope you can help