title: Load and keep variables / objects accessible between files in python Flask server
body: <p>When I start my flask app, I want it to immediately load an object, and I want this object to be available to functions defined in other files.  </p>
  
  <p>The way things are set up now is as follows:</p>
  
  <pre><code>object = someObjectToLoadAtServerStartAndAlwaysKeepInMemoryAndAccessFromAnyPyFile
  </code></pre>
  
  <p>In run.py, located in folder Project:</p>
  
  <pre><code>from app import app
  app.run(debug = True)
  </code></pre>
  
  <p>In __init__.py, located in Project/app:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  from app import views
  </code></pre>
  
  <p>In views.py, located in Project/app:</p>
  
  <pre><code>from app import app
  @app.route('/page')
  def func():
    #access preloaded variable here#
  </code></pre>
  
  <p>Note that I want the object (which is saved to a file) to be loaded immediately after the app is started, and maintained forever as long as the app is running.  I have tried any number of things, defining the object everywhere I can, and using global, but it is never accessible to func()</p>
  
  <p>If I define it on top of views.py, will it load even no one has used one of the @app.routes?</p>