Debugging
VS Code
In VS Code, you can create a launch.json
file that allows you to add breakpoints and step through your API code. Here are the steps:
- Open your project in VS Code.
- Click the debug menu on the sidebar.
- Click
create a launch.json file
- Choose
Python
as the language. - I typically choose
Python File
as the template, and then just add the following to the configuration.
{
"configurations": [
{
"name": "Dev Ngrok",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app:create_app('Ngrok')",
"FLASK_ENV": "development",
"FLASK_DEBUG": "0"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
]
}
]
}
- The debug configuration should now show up in the debug menu on the sidebar. Now you can add break points to your code and click the Green Triangle button to run your flask application.
If you want to run the application with a different configuration mode, you can replace the Ngrok
in app:create_app('Ngrok')
with any other config mode.
You can learn more about the VS Code debugger here and more about debugging Python applications here