title: How to share the global app object in flask?
body: <p>I am using flask and trying to the following. </p>
  
  <p>I have defined a main.py file through which I want to run my app ie python main.py -</p>
  
  <pre><code>from flask import Flask
  from view import tags
  
  app = Flask(__name__)
  
  @app.route('/')
  def hello_world():
      return 'Hello World!'
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>I have defined a package named view in which I will be declaring my different view modules, each having its own routes. view.tags.py -</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route('/e')
  def hello_world2():
      return 'Hello World!'
  </code></pre>
  
  <p>So I need to have the global app object in my main.py for running the server, as well as in the view classes of my package for registering the routes. So how do I create the global app object and share it between all classes ?</p>
  
  <p>Thanks,
  Murtaza </p>