Connexion: Debugging in vscode does not work with connexion

Created on 23 May 2019  路  4Comments  路  Source: zalando/connexion

Following the instructions in (https://code.visualstudio.com/docs/python/tutorial-flask) to run the code in vscode debugger throws the error:
Error: Failed to find Flask application or factory in module "app". Use "FLASK_APP=app:name to specify one.

The reason in that the app is created by:
app = connexion.FlaskApp(__name__)
instead of:
app = Flask(__name__)

So the FLASK_APP could not be recognized.

Is there a workaround for this to enable debugging in vscode?

Most helpful comment

Add this config profile to the workspace .vscode/launch.json:

        {
            "name": "Python: Connexion",
            "type": "python",
            "request": "launch",
            "module": "connexion",
            "cwd": "${workspaceFolder}",
            "env": {
                ...
            },
            "args": [
                "run",
                "[SPEC_DIR]/[SPEC_FILE]",
                "--port",
                "[HTTP_PORT]"
            ]
        }

All 4 comments

Same problem for me. Any idea?

Can you post the your launch.json file? I suspect the FLASK_APP value starts with "{workspaceFolder}...".

NOTE: I've been at this a while and still have not successfully been able to debug a Flask/Connexion app in VSCode, but I have made it past the error you posted.

Add this config profile to the workspace .vscode/launch.json:

        {
            "name": "Python: Connexion",
            "type": "python",
            "request": "launch",
            "module": "connexion",
            "cwd": "${workspaceFolder}",
            "env": {
                ...
            },
            "args": [
                "run",
                "[SPEC_DIR]/[SPEC_FILE]",
                "--port",
                "[HTTP_PORT]"
            ]
        }

That launch config works for me.

Was this page helpful?
0 / 5 - 0 ratings