I created a Flask web page (within PythonAnywhere) requesting data in a polling situation via AJAX calls.
There are some complex object structures that cannot (easily) be jsonified and need to be maintained during the life of that page.
On my Windows PC I created an object in app and just read/updated as needed. That paradigm does not work in PythonAnywhere (nor do I believe it to be an optimal solution anyway). PythonAnywhere does not support redis or memcached (so that route is taken away). I could write it out to SQLite but have a feeling there are other options.
Any ideas on the best approach to access/modify my Flask objects during the AJAX calls?
My program is constructed like:
@app.route('/view_page')
@login_required
def view_page(program_selection):
create_object=cc(current_user)
render_template('myview.html', somevars=current_user.username)
@app.route('/_myajax_call')
@login_required
def ajax_call():
# Need to get create_object here
some_data = some_function(create_object)
return jsonify(result=some_data)
Also posted on stackoverflow How to maintain state during Flask AJAX requests