title: How to maintain state during Flask AJAX requests
body: <p>I created a Flask web page (<em>within PythonAnywhere</em>) requesting data in a polling situation via AJAX calls.</p>
  
  <p>There are some complex object structures that cannot (easily) be jsonified and need to be maintained during the life of that page.  </p>
  
  <p>On my Windows PC I created an object in app and just read/updated as needed. That paradigm does not work in PythonAnywhere (<em>nor do I believe it to be an optimal solution anyway</em>).  PythonAnywhere does not support redis or memcached (<em>so that route is taken away</em>).  I could write it out to SQLite but have a feeling there are other options.</p>
  
  <p>Any ideas on the best approach to access/modify my Flask objects during the AJAX calls?</p>
  
  <p>My program is constructed like:</p>
  
  <pre><code>@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)
  </code></pre>