Skip to content

How FastAPI maps paths to methods? #2013

@vovean

Description

@vovean

I was going through the tutorial, the First Steps part.
When I got to the point where we declare a GET path with @app.get("/") I decided to look inside the app.get code. I expected to see several nested methods, as it usually happens when we create decorators. However, there is quite a simple code that (I believe) adds a GET record to the app's router.
Moreover, I have not seen any manipulations with the method which is decorated by @app.get("/").
So, now I am wondering, where exactly does the decorated method get assigned to the related path?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions