Skip to content

Detecting and configuring a FastAPI project for debugging #5136

Answered by tiangolo
brettcannon asked this question in Questions
Discussion options

You must be logged in to vote

This is awesome!

Here are the heuristics:

File

The main file would be:

  • main.py

After that, the next most common options would be:

  • app/main.py
  • app.py

And other possible but probable quite less common options:

  • app/app.py
  • api.py
  • app/api.py
  • api/main.py

Object

Inside of that file, there would normally be an object app. It would be an instance of the class FastAPI(). The instantiation would normally be in that same file.

The symbol/class FastAPI comes from fastapi.FastAPI (exported in the __init__.py of the package), and is defined in fastapi.applications.FastAPI.

Another possible name for that object would be api, but probably not too common.

Config

The JSON object at .vscode/launch.json

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
9 replies
@brettcannon
Comment options

@adriangb
Comment options

@brettcannon
Comment options

@adriangb
Comment options

@brettcannon
Comment options

Comment options

You must be logged in to vote
1 reply
@Kludex
Comment options

Answer selected by brettcannon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants