title: How to pass arbitrary arguments to a flask blueprint?
body: <p>I have a flask api which I have wrapped up in an object. Doing this has made unit testing a breeze, because I can instantiate the api with a variety of different settings depending on whether it is in production, test, or whatehaveyou. </p>
  
  <p>I am now trying to extend the api a bit, and for that I'm using a blueprint. The problem is that I cannot figure out how to pass arguments to the blueprint. My routes require information like which database to access, and that information is not static. How can I pass this information into a blueprint? I have included code below as an example:</p>
  
  <p>api.py:</p>
  
  <pre><code>class MyApi(object):
      def __init__(self, databaseURI):
       self.app = Flask(__name__)
       self.app.register_blueprint(myblueprint)
  </code></pre>
  
  <p>blueprint.py</p>
  
  <pre><code>myblueprint= Blueprint('myblueprint', __name__)
  @myblueprint.route('/route', methods=['GET'])
  def route():
    database = OpenDatabaseConnection(databaseURI)
  </code></pre>
  
  <p>There is a related question here:
  <a href="https://stackoverflow.com/questions/21969973/how-do-i-pass-constructor-arguments-to-a-flask-blueprint">How do I pass constructor arguments to a Flask Blueprint?</a></p>
  
  <p>But the people who answer the question solve the op's use-case specific problem <em>without</em> actually answering the question of how to pass arbitrary arguments to a blueprint.</p>