Home / File/ items.py — fastapi Source File

items.py — fastapi Source File

Architecture documentation for items.py, a python file in the fastapi codebase. 2 imports, 0 dependents.

File python FastAPI Applications 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  f8da3411_723e_0a0b_93ab_a9759a2c1248["items.py"]
  f81189ef_7e85_86da_5790_4c859fd886da["dependencies"]
  f8da3411_723e_0a0b_93ab_a9759a2c1248 --> f81189ef_7e85_86da_5790_4c859fd886da
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  f8da3411_723e_0a0b_93ab_a9759a2c1248 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  style f8da3411_723e_0a0b_93ab_a9759a2c1248 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import APIRouter, Depends, HTTPException

from ..dependencies import get_token_header

router = APIRouter(
    prefix="/items",
    tags=["items"],
    dependencies=[Depends(get_token_header)],
    responses={404: {"description": "Not found"}},
)


fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}


@router.get("/")
async def read_items():
    return fake_items_db


@router.get("/{item_id}")
async def read_item(item_id: str):
    if item_id not in fake_items_db:
        raise HTTPException(status_code=404, detail="Item not found")
    return {"name": fake_items_db[item_id]["name"], "item_id": item_id}


@router.put(
    "/{item_id}",
    tags=["custom"],
    responses={403: {"description": "Operation forbidden"}},
)
async def update_item(item_id: str):
    if item_id != "plumbus":
        raise HTTPException(
            status_code=403, detail="You can only update the item: plumbus"
        )
    return {"item_id": item_id, "name": "The great Plumbus"}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does items.py do?
items.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in items.py?
items.py defines 3 function(s): read_item, read_items, update_item.
What does items.py depend on?
items.py imports 2 module(s): __init__.py, dependencies.
Where is items.py in the architecture?
items.py is located at docs_src/bigger_applications/app_py39/routers/items.py (domain: FastAPI, subdomain: Applications, directory: docs_src/bigger_applications/app_py39/routers).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free