... fastapi: routes


In this library you'll use decorators like @get.route("/") to describe the where the request can go while the function that follows describes how it is handled. Note that these functions are typically typed, which means that you can explicitly state what type of variables it should assume.

The app.py file at the end of our video looks like this;

from fastapi import FastAPI

app = FastAPI()

def root():
    return {"message": "hello world again"}

def read_user(user_id: str):
    return {"user_id": user_id}

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.