Nov-15-2021, 04:38 PM
Hello everyone,
I am trying to add Flask RestPlus to a project that has worked heavily in only using Flask and FlaskCors
I have been trying to use RestPlus as a way to help us have swagger documentation but I am running into some issues
The main piece of code that instantiates everything is written as follows
I am trying to add Flask RestPlus to a project that has worked heavily in only using Flask and FlaskCors
I have been trying to use RestPlus as a way to help us have swagger documentation but I am running into some issues
The main piece of code that instantiates everything is written as follows
def api_prefix(app): return f'/api/{app.config.get("API_VERSION", "v1")}' def create_app() -> Flask: app = Flask(__name__, instance_relative_config=True) load_app_config(app) CORS(app, resources={'*': {'origins': app.config['CORS_ORIGINS']}}) contentful_client.init_app(app) @app.route('/healthpoke') def healthpoke(): return 'OUCH!', 200 apis = [ test_api, test2_api, test3_api, ] for api in apis: app.register_blueprint(api, url_prefix=api_prefix(app)) # register root/standalone blueprints (self versioned) app.register_blueprint(test4_api) app.register_blueprint(test5_api) app.register_blueprint(test6_api) return app app = create_app()But when I try to use it with RestPlus, I run into issues with how it's all handled
def create_app() -> Api: api = Flask(__name__, instance_relative_config=True) app = Api(app=api) load_app_config(app) CORS(app, resources={'*': {'origins': app.config['CORS_ORIGINS']}}) api.init_app(app) contentful_client.init_app(app) @api.route('/healthpoke') def healthpoke(): return 'OUCH!', 200And when I try running, I get this error
Error:AttributeError: Api does not have config attribute
Is there anything I should be looking for?