In symplified case we've got a projects and files. Files belong to projects. Every of them has their own router to perfom CRUD actions via API.
So, in code it should look like this:
from fastapi import FastAPI, APIRouter
app = FastAPI()
projects_router = APIRouter()
files_router = APIRouter()
app.include_router(projects_router, prefix="/projects")
projects_router.include_router(files_router, prefix="/{project_id}/files")
@files_router.get("/")
def list_files(project_id: int):
# Some code, that list all project's files by project_id
But the list_files
function can't get project_id
. How can it?