I do not understand how to do it right.
blueprint api:
# coding: utf-8 from flask import Blueprint, render_template from ..models import User from flask_restless import APIManager manager = APIManager() manager.create_api(User, url_prefix='/api', methods=['GET', 'POST', 'DELETE', 'PUT', 'PATCH']) bp = Blueprint('api', __name__) in __init__.py :
def register_db(app): from .models import db db.init_app(app) def register_api(app): from .controllers.api import manager manager.init_app(app, flask_sqlalchemy_db=db) Below is how I connect blueprints:
def register_routes(app): from . import controllers from flask.blueprints import Blueprint for module in _import_submodules_from_package(controllers): bp = getattr(module, 'bp') if bp and isinstance(bp, Blueprint): app.register_blueprint(bp) I get this error when starting the application:
RuntimeError: application not registered on the current context
If I exclude methods=['GET', 'POST', 'DELETE', 'PUT', 'PATCH'] , then the application is launched, but the http http://0.0.0.0:5000/api/user request http http://0.0.0.0:5000/api/user obviously gives answer:
HTTP/1.0 500 INTERNAL SERVER ERROR Content-Length: 291 Content-Type: text/html Date: Thu, 20 Oct 2016 15:33:52 GMT Server: Werkzeug/0.11.11 Python/3.5.2 The documentation shows an example, but there is a slightly different application structure.
Tell me, please, how to solve the problem correctly.