Skip to content

Debugging: Flask

Don Jayamanne edited this page Sep 5, 2016 · 5 revisions

Debugging Flask Applications is as simple as debugging any other Python Application.
The following section uses the sample application outlined here. The sample flask application can be downloaded form here.

  • Download and extract the above flask application
  • Open the directory in Visual Studio Code
  • Modify the run.py file as follows:
#!flask/bin/python
from app import app

#Do not add debug=True
#app.run(debug=True)

app.run()
  • Debug the Flask application using the standard Python debug configuration (see below):
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },

Note:

  • Breakpoints added to the views work as expected
Clone this wiki locally