title: Pass another object to the main flask application
body: <p>I got a doubt about how to pass an object to a flask app in the correct way.</p>
  
  <p>The idea is simple. </p>
  
  <p>I wan to create an api for my application, which means that http requests processed by my flask application will trigger methods in my main application.</p>
  
  <p>For that, I need flask to be aware of my other process, one way or another.</p>
  
  <p>Currently, I have something like : </p>
  
  <pre><code>if __name__ == '__main__':
      Logger = MyProcess()
      app.run()
  </code></pre>
  
  <p>I need to be able to do something like that : </p>
  
  <pre><code>@app.route('/nb_trendy')
  def nb_trendy():
  
      res = Logger.get_trendy()
      return jsonify(res)
  </code></pre>
  
  <p>which means that I either need to either give a handle on Logger to app, or directly define Logger inside app.</p>
  
  <p>But in each of the solutions I can find, I need to create a class that <strong>inherits</strong> app, to either override <strong><code>__init__()</code></strong> and takes objects as parameters, or modify the <strong><code>run()</code></strong> method.</p>
  
  <p>the current way I would do it is though : </p>
  
  <pre><code>class MyFlask(Flask):
      def __init__():
          Flask.__init__()
          Logger = MyProcess()
  </code></pre>
  
  <p>Is this also the way you would do it, or is there a better way to do this?</p>
  
  <p>Thanks!</p>
  
  <p>Here is a more general version of this question: <a href="https://stackoverflow.com/questions/14891848/web-api-in-flask">Web API in Flask</a></p>