Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        Sign in or join
        Opening Python for software engineers
        Your turn

        FastAPI path operations

        Routes, methods and responses

        A FastAPI app maps an HTTP method and a path to a Python function. @app.get("/plots/current") answers GET on that path. FastAPI itself answers 405 when a known path gets another method and 404 for a path it does not know, and it turns the value you return into JSON. Each exercise builds its own app and sends requests through HTTPX’s ASGITransport, so you see the real status codes and bodies without starting a server.

        What runs in the browser

        The exercises run FastAPI 0.136.1, Pydantic 2.12.5 and HTTPX 0.28.1 on a Python runtime in your browser. Handlers use async def, because synchronous routes need a thread pool the browser does not have. The FastAPI tutorial shows how to run the same code under a server such as Uvicorn. The next lessons in the unit add path and query validation, Pydantic request models, response models and HTTP errors.

        Guides on this topic

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        Your account can start a 5-day free trial: every course, unit, project and exam. Card needed; cancel any time and pay nothing.

        New accounts get 6 hours of full access: every course, unit, project and exam. The clock starts when you go past the free lessons.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Change your plan

        Checking the price

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.