FastAPI: a Python backend

Lesson 01 · 9 min

A first app

A decorator over a function, and you have a route with docs.

9 minLesson 1 of 9Practice includedAsk AI on any point

FastAPI builds routes from decorators: @app.get("/") over a function. A returned dict becomes JSON. The uvicorn server runs the app. At /docs there's interactive Swagger documentation right away, generated from your functions and types.

main.py
AI

You can ask about this rule«async def when you wait on I/O»

  • A virtual environment: python -m venv .venv, then activate it.
  • Dependencies are pinned in requirements.txt or pyproject.toml.
  • /redoc is another documentation view.
AI

You can ask about this point«Lesson summary»

Check

Lock it in before you move on

  1. 1. Where is the API documentation in FastAPI?

  2. 2. A function returned a dict. What does the client get?

  3. 3. When do you write async def?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice