Home / File/ tutorial006_py39.py — fastapi Source File

tutorial006_py39.py — fastapi Source File

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

File python FastAPI Routing 7 imports 1 dependents 3 functions

Entity Profile

Dependency Diagram

graph LR
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75["tutorial006_py39.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  2d259205_f589_7dee_455a_60e1c67ed35e["exception_handlers.py"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 2d259205_f589_7dee_455a_60e1c67ed35e
  b7aaa327_256c_826b_6da4_7f2714292af0["http_exception_handler"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> b7aaa327_256c_826b_6da4_7f2714292af0
  2d028bc8_34b4_6303_1406_f7c12b4394e6["request_validation_exception_handler"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 2d028bc8_34b4_6303_1406_f7c12b4394e6
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 01c652c5_d85c_f45e_848e_412c94ea4172
  58bb043a_10d8_c308_5564_225558a63815["RequestValidationError"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 58bb043a_10d8_c308_5564_225558a63815
  72a586ac_ceef_ac9f_17ec_0ed0d645b635["starlette.exceptions"]
  46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 --> 72a586ac_ceef_ac9f_17ec_0ed0d645b635
  4d886d63_bd76_234e_87d8_d2b6bc472afe["test_tutorial006.py"]
  4d886d63_bd76_234e_87d8_d2b6bc472afe --> 46d0b5a1_0a29_e7e1_5201_61b2c63c0e75
  style 46d0b5a1_0a29_e7e1_5201_61b2c63c0e75 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import FastAPI, HTTPException
from fastapi.exception_handlers import (
    http_exception_handler,
    request_validation_exception_handler,
)
from fastapi.exceptions import RequestValidationError
from starlette.exceptions import HTTPException as StarletteHTTPException

app = FastAPI()


@app.exception_handler(StarletteHTTPException)
async def custom_http_exception_handler(request, exc):
    print(f"OMG! An HTTP error!: {repr(exc)}")
    return await http_exception_handler(request, exc)


@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
    print(f"OMG! The client sent invalid data!: {exc}")
    return await request_validation_exception_handler(request, exc)


@app.get("/items/{item_id}")
async def read_item(item_id: int):
    if item_id == 3:
        raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
    return {"item_id": item_id}

Domain

Subdomains

Frequently Asked Questions

What does tutorial006_py39.py do?
tutorial006_py39.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in tutorial006_py39.py?
tutorial006_py39.py defines 3 function(s): custom_http_exception_handler, read_item, validation_exception_handler.
What does tutorial006_py39.py depend on?
tutorial006_py39.py imports 7 module(s): RequestValidationError, __init__.py, exception_handlers.py, exceptions.py, http_exception_handler, request_validation_exception_handler, starlette.exceptions.
What files import tutorial006_py39.py?
tutorial006_py39.py is imported by 1 file(s): test_tutorial006.py.
Where is tutorial006_py39.py in the architecture?
tutorial006_py39.py is located at docs_src/handling_errors/tutorial006_py39.py (domain: FastAPI, subdomain: Routing, 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