title: Using Flask Restful as a Blueprint in Large Application
body: <p>I am trying to use Flask restful as a Blueprint in a pattern that works for other blueprints. I keep getting the following error message</p>
  
  <p>I get the following error message </p>
  
  <blockquote>
    <p>AttributeError: 'Blueprint' object has no attribute 'add_resource'</p>
  </blockquote>
  
  <p>My project setup is as follows:</p>
  
  <p><strong>Folder structure</strong></p>
  
  <pre><code>├── app
  │   ├── __init__.py
  │   ├── api
  │   │   ├── __init__.py
  │   │   └── routes.py
  │   ├── main
  │   │   ├── __init__.py
  │   │   ├── forms.py
  │   │   └── views.py
  │   └── templates
  │       ├── base.html
  │       └── home.html
  ├── config.py
  ├── manage.py
  └── requirements.txt
  </code></pre>
  
  <p><strong>__init__.py</strong></p>
  
  <pre><code>from flask import Flask
  from flask_restful import Api
  from flask_bootstrap import Bootstrap
  from config import config
  bootstrap = Bootstrap()
  api = Api()
  
  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)
      api.init_app(app)
  
      from .main import main as main_blueprint
      from .api import api as api_blueprint
      app.register_blueprint(main_blueprint)
      app.register_blueprint(api_blueprint)
      return app
  </code></pre>
  
  <p><strong>api/__init__.py</strong></p>
  
  <pre><code>from flask import Blueprint
  
  api = Blueprint('api', __name__)
  
  from . import routes
  </code></pre>
  
  <p><strong>api/routes.py</strong></p>
  
  <pre><code>from flask_restful import Resource
  from . import api
  
  class TodoItem(Resource):
      def get(self, id):
          return {'task': 'Say "Hello, World!"'}
  
  api.add_resource(TodoItem, '/todos/&lt;int:id&gt;')
  </code></pre>
  
  <p>What am I doing wrong??</p>