tutorial001_py310.py — fastapi Source File
Architecture documentation for tutorial001_py310.py, a python file in the fastapi codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 51488fb9_b57a_8718_8072_ca39d27a6025["tutorial001_py310.py"] fda8f0bb_782c_0c24_7ae3_e174de491ade["gzip"] 51488fb9_b57a_8718_8072_ca39d27a6025 --> fda8f0bb_782c_0c24_7ae3_e174de491ade 07d79a2e_d4e9_0bbb_be90_936274444c8c["collections.abc"] 51488fb9_b57a_8718_8072_ca39d27a6025 --> 07d79a2e_d4e9_0bbb_be90_936274444c8c 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 51488fb9_b57a_8718_8072_ca39d27a6025 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"] 51488fb9_b57a_8718_8072_ca39d27a6025 --> de395a51_26f8_3424_1af0_2f5bef39c893 aa28685f_bb97_e988_ff40_3e5385960f32["APIRoute"] 51488fb9_b57a_8718_8072_ca39d27a6025 --> aa28685f_bb97_e988_ff40_3e5385960f32 style 51488fb9_b57a_8718_8072_ca39d27a6025 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import gzip
from collections.abc import Callable
from fastapi import Body, FastAPI, Request, Response
from fastapi.routing import APIRoute
class GzipRequest(Request):
async def body(self) -> bytes:
if not hasattr(self, "_body"):
body = await super().body()
if "gzip" in self.headers.getlist("Content-Encoding"):
body = gzip.decompress(body)
self._body = body
return self._body
class GzipRoute(APIRoute):
def get_route_handler(self) -> Callable:
original_route_handler = super().get_route_handler()
async def custom_route_handler(request: Request) -> Response:
request = GzipRequest(request.scope, request.receive)
return await original_route_handler(request)
return custom_route_handler
app = FastAPI()
app.router.route_class = GzipRoute
@app.post("/sum")
async def sum_numbers(numbers: list[int] = Body()):
return {"sum": sum(numbers)}
Domain
Subdomains
Functions
Classes
Dependencies
- APIRoute
- __init__.py
- collections.abc
- gzip
- routing.py
Source
Frequently Asked Questions
What does tutorial001_py310.py do?
tutorial001_py310.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 tutorial001_py310.py?
tutorial001_py310.py defines 1 function(s): sum_numbers.
What does tutorial001_py310.py depend on?
tutorial001_py310.py imports 5 module(s): APIRoute, __init__.py, collections.abc, gzip, routing.py.
Where is tutorial001_py310.py in the architecture?
tutorial001_py310.py is located at docs_src/custom_request_and_route/tutorial001_py310.py (domain: FastAPI, subdomain: Responses, directory: docs_src/custom_request_and_route).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free