Vscode-python: FastAPI Debugger

Created on 3 Oct 2020  路  5Comments  路  Source: microsoft/vscode-python

Description

As a VSCode user I want to be able to debug my FastAPI application. :tada:

More information

The web framework is growing and I think the community will benefit from this feature. :sunglasses:

Notes

  • I'll be working on this. I'll link the PR when I've finished. :factory_worker:
  • Please let me know if this feature will not be accepted, so I stop working on it :sunflower:

Updates

November 4, 2020: Running successfully. Tests and other requirements are missing. PR: #14606
image

area-debugging needs PR type-enhancement

Most helpful comment

This is awesome @Kludex ! :rocket: I'm very excited about it. :star_struck:

I have been intending to do something around it but I haven't had the time.


As you are working on it, in case it's useful, let me share what I currently do.

I normally create the file .vscode/launch.json "by hand" and have these two main configurations, one for a single file and one for a bigger application assuming it lives at app/main.py.

        {
            "name": "Python: FastAPI - current file",
            "type": "python",
            "request": "launch",
            "cwd": "${fileDirname}",
            "module": "uvicorn",
            "args": [
                "${fileBasenameNoExtension}:app"
            ],
            "jinja": true
        },
        {
            "name": "Python: FastAPI - app",
            "type": "python",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "app.main:app"
            ],
            "jinja": true
        },

It's all based on the default Flask configs and it works very well. But it would be great if it was included by default as a template (like Django and Flask) in VS Code.

All 5 comments

This is awesome @Kludex ! :rocket: I'm very excited about it. :star_struck:

I have been intending to do something around it but I haven't had the time.


As you are working on it, in case it's useful, let me share what I currently do.

I normally create the file .vscode/launch.json "by hand" and have these two main configurations, one for a single file and one for a bigger application assuming it lives at app/main.py.

        {
            "name": "Python: FastAPI - current file",
            "type": "python",
            "request": "launch",
            "cwd": "${fileDirname}",
            "module": "uvicorn",
            "args": [
                "${fileBasenameNoExtension}:app"
            ],
            "jinja": true
        },
        {
            "name": "Python: FastAPI - app",
            "type": "python",
            "request": "launch",
            "module": "uvicorn",
            "args": [
                "app.main:app"
            ],
            "jinja": true
        },

It's all based on the default Flask configs and it works very well. But it would be great if it was included by default as a template (like Django and Flask) in VS Code.

@tiangolo I'm impressed that you found this issue so fast! :1st_place_medal:

I'll probably finish it in the following days. Thank you for the snippet! :tada:

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 馃憤 votes the opening comment gets to help us make our decision.

We plan to leave this feature request open for at least a month to see how many :+1: [...]

Awesome! In that case, this deserves a tweet :sweat_smile:

https://twitter.com/tiangolo/status/1313777692077166593

And just a heads-up that even if we don't accept this (we have not started discussing this yet, so this isn't foreshadowing), there is https://github.com/Microsoft/vscode-recipes for keeping this sort of thing in a centralized place for VS Code users. So any thinking or work to come up with a reasonable template will not go to waste one way or another.

Was this page helpful?
5 / 5 - 1 ratings