Home / File/ tutorial003_py39.py — fastapi Source File

tutorial003_py39.py — fastapi Source File

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

File python FastAPI Responses 2 imports 1 dependents 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  64279567_ee7c_8571_3115_40b3aaced25f["tutorial003_py39.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  64279567_ee7c_8571_3115_40b3aaced25f --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  64279567_ee7c_8571_3115_40b3aaced25f --> 967b6712_70e2_f5fa_f671_7c149857a445
  3952d1cb_22c0_ed42_4930_4c4b43f9f4ce["test_tutorial003.py"]
  3952d1cb_22c0_ed42_4930_4c4b43f9f4ce --> 64279567_ee7c_8571_3115_40b3aaced25f
  style 64279567_ee7c_8571_3115_40b3aaced25f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse


class UnicornException(Exception):
    def __init__(self, name: str):
        self.name = name


app = FastAPI()


@app.exception_handler(UnicornException)
async def unicorn_exception_handler(request: Request, exc: UnicornException):
    return JSONResponse(
        status_code=418,
        content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
    )


@app.get("/unicorns/{name}")
async def read_unicorn(name: str):
    if name == "yolo":
        raise UnicornException(name=name)
    return {"unicorn_name": name}

Domain

Subdomains

Frequently Asked Questions

What does tutorial003_py39.py do?
tutorial003_py39.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in tutorial003_py39.py?
tutorial003_py39.py defines 2 function(s): read_unicorn, unicorn_exception_handler.
What does tutorial003_py39.py depend on?
tutorial003_py39.py imports 2 module(s): __init__.py, responses.py.
What files import tutorial003_py39.py?
tutorial003_py39.py is imported by 1 file(s): test_tutorial003.py.
Where is tutorial003_py39.py in the architecture?
tutorial003_py39.py is located at docs_src/handling_errors/tutorial003_py39.py (domain: FastAPI, subdomain: Responses, directory: docs_src/handling_errors).

Analyze Your Own Codebase

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

Try Supermodel Free