title: Flask register_blueprint error (Python)
body: <p>I have a project on Flask. And when I include Blueprint on my Flask app I have errors. The code is from a book, Miguel Grinberg about Flask.</p>
  
  <p>Project tree:</p>
  
  <pre><code>.
  ├── app
  │   ├── __init__.py
  │   ├── main
  │   │   ├── errors.py
  │   │   ├── __init__.py
  │   │   └── views.py
  │   ├── static
  │   │   ├── static_files
  │   └── templates
  │       └── html_files
  ├── config.py
  ├── manage.py
  </code></pre>
  
  <p>create_app() in <strong>app/__init__.py</strong></p>
  
  <pre><code>def create_app(config_name):
      app = Flask(__name__)
      app.config.from_object(config[config_name])
      config[config_name].init_app(app)
      bootstrap.init_app(app)
      db.init_app(app)
  
      from .main import main as main_blueprint
      app.register_blueprint(main_blueprint)   
  
      return app
  </code></pre>
  
  <p>listing <strong>app/main/__init__.py</strong></p>
  
  <pre><code>from flask import Blueprint
  
  main = Blueprint('main', __name__)
  
  from . import views, errors
  </code></pre>
  
  <p>Passenger row process output </p>
  
  <pre><code>Traceback (most recent call last):
    File "/opt/passenger/passenger-4.0.57/helper-scripts/wsgi-loader.py", line 320, in &lt;module&gt;
      app_module = load_app()
    File "/opt/passenger/passenger-4.0.57/helper-scripts/wsgi-loader.py", line 61, in load_app
      return imp.load_source('passenger_wsgi', startup_file)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/imp.py", line 171, in load_source
      module = methods.load()
    File "&lt;frozen importlib._bootstrap&gt;", line 1220, in load
    File "&lt;frozen importlib._bootstrap&gt;", line 1200, in _load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 1129, in _exec
    File "&lt;frozen importlib._bootstrap&gt;", line 1471, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 321, in _call_with_frames_removed
    File "passenger_wsgi.py", line 16, in &lt;module&gt;
      from manage import app as application
    File "/home/m/mallts/dev.wget-studio.ru/fikls/manage.py", line 7, in &lt;module&gt;
      app = create_app('default') #(os.getenv('FLASK_CONFIG') or 'default')
    File "/home/m/mallts/dev.wget-studio.ru/fikls/app/__init__.py", line 19, in create_app
      app.register_blueprint(main_blueprint)   
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/app.py", line 62, in wrapper_func
      return f(self, *args, **kwargs)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/app.py", line 889, in register_blueprint
      blueprint.register(self, options, first_registration)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/blueprints.py", line 153, in register
      deferred(state)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/blueprints.py", line 128, in wrapper
      func(state)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/blueprints.py", line 399, in &lt;lambda&gt;
      self.name, code_or_exception, f))
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/app.py", line 62, in wrapper_func
      return f(self, *args, **kwargs)
    File "/home/m/mallts/dev.wget-studio.ru/myenv/lib/python3.4/site-packages/flask/app.py", line 1090, in _register_error_handler
      'It is currently not possible to register a 500 internal ' \
  AssertionError: It is currently not possible to register a 500 internal server error on a per-blueprint level.
  </code></pre>
  
  <p>My <strong>app/main/errors.py</strong></p>
  
  <pre><code>from flask import render_template
  from . import main 
  
  @main.errorhandler(404)
  def page_not_found(e):
      return render_template('404.html'), 404
  
  @main.errorhandler(500)
  def internal_server_error(e):
      return render_template('500.html'), 500
  </code></pre>
  
  <p>My <strong>app/main/views.py</strong></p>
  
  <pre><code>from flask import render_template, url_for, session, redirect
  from . import main 
  
  @main.route('/')
  def index():
      return render_template('index.html')
  </code></pre>