Connexion: How do I access Flask current_app?

Created on 12 Jul 2018  路  6Comments  路  Source: zalando/connexion

server.py

#!/usr/bin/env python3

from connexion.resolver import RestyResolver
import connexion

def create_app():
    app = connexion.FlaskApp(__name__, specification_dir='swagger/')
    app.add_api('mapmybook.yaml',validate_responses=True, strict_validation=True, resolver=RestyResolver('api'))

    return app

if __name__ == '__main__':
    create_app().run(port=9090)
api/routes.py

from flask import current_app
def get() -> list:
    print(current_app)
    return items

results in RuntimeError: Working outside of application context.
I'm using Flask 1.0 with connexion 1.4.2, creating the app as seen above. Is there a way to access Flask's current_app from other modules?
I keep getting RuntimeError: Working outside of application context. when calling current_app in API modules.

Most helpful comment

Can we re-open this?

All 6 comments

Got it, app context is only available under certain conditions.

@zimmicz I still get these errors. Can you let me know how you solved your issue? I've tried so many things but I always get this error...

Same issue here...

Can we re-open this?

Any update on this? :\

Was this page helpful?
0 / 5 - 0 ratings

Related issues

advance512 picture advance512  路  3Comments

majoros picture majoros  路  5Comments

davidnazw picture davidnazw  路  4Comments

writeson picture writeson  路  4Comments

braco picture braco  路  3Comments