title: How to add views to a blueprint in separate files
body: <p>I have a huge application that was getting hard to update its views. To 'fix' this, I had separate the views into a few files, using <a href="http://flask.pocoo.org/docs/1.0/blueprints/" rel="nofollow noreferrer">blueprints</a>. The problem is that the blueprints are also getting very big, because the long documentation that each view has and the different verifications that each view requires.</p>
  
  <p>I had tried to do an <code>import</code> like this:</p>
  
  <p><img src="https://i.imgur.com/vcrpsX6.png" alt="Import"></p>
  
  <p>Where I have a main file that contains the Flask application (which imports the blueprint), a file that contains the blueprint and a file the imports the blueprint and configure the views in it. The problem is that with this approach the views are not rendered, because flow reasons.</p>
  
  <p>The main file, in the root of a folder:</p>
  
  <pre class="lang-py prettyprint-override"><code>from flask import Flask
  
  from source import test
  
  application = Flask(__name__)
  
  application.register_blueprint(test)
  
  application.run()
  </code></pre>
  
  <p>The blueprint file, inside a subfolder in the root folder:</p>
  
  <pre class="lang-py prettyprint-override"><code>from flask import Blueprint
  
  test = Blueprint('test', __name__)
  </code></pre>
  
  <p>The view file, inside the same subfolder as the blueprint file:</p>
  
  <pre class="lang-py prettyprint-override"><code>from .test import test
  
  @test.route('/home', methods=['GET', 'POST'])
  def home():
      return 'home'
  </code></pre>
  
  <p>I had also tried to add the blueprint decorator to a declared function, this way the views are add to the blueprint in the blueprint file, but I don't think this is a good approach or a scalable approach - and it didn't work ^ - ^.</p>
  
  <p>I expect to create a blueprint in a file, import the blueprint in other files and add views to the blueprint and then import the blueprint and add it to the Flask application.</p>