{"id":343367,"date":"2022-12-30T15:01:57","date_gmt":"2022-12-30T15:01:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=343367"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=343367","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c FastAPI \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0434\u0435\u0441\u044c, \u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 FastAPI. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f API. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ASGI-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u043a\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0435\u0433\u043e.<\/p>\n<p>\u0418 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0432, \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u043a\u0430\u043a \u044f\u0441\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c FastAPI. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043e\u043d \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 Starlette, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 ASGI, \u0438 \u043d\u0430 Pydantic, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. FastAPI \u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438.<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043f\u043e \u0438\u0442\u043e\u0433\u0443 \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c FastAPI, \u0441 \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c myfastapi.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e\u0435 \u043d\u0430 fastapi \u0441 \u043f\u043e\u043c\u043e\u0449\u044c myfastapi.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0427\u0442\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c<\/h2>\n<p>\u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 FastAPI, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Starlette, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0440\u043e\u0443\u0442\u044b \u0432 \u043a\u043b\u0430\u0441\u0441 Starlette. \u042d\u0442\u0438 \u0440\u043e\u0443\u0442\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0442\u0430\u043c \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0445\u043e\u0441\u0442\u0443 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0441 ASGI \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <em>Scope<\/em>, <em>Receive<\/em> \u0438 <em>Send<\/em>. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u0442\u043e\u0447\u043d\u0435\u0435 \u043a\u043b\u0430\u0441\u0441\u0443, \u043d\u0443\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <strong>__call__<\/strong>. \u0414\u0430\u043d\u043d\u044b\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 FastAPI \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438\u0448\u044c \u0432 \u0432\u0438\u0434\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <strong>super().__call__<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 Starlette. \u041d\u043e \u043f\u043e\u043a\u0430 Starlette \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442, \u0434\u043e \u043d\u0435\u0433\u043e \u043c\u044b \u0435\u0449\u0435 \u0434\u043e\u0439\u0434\u0435\u043c.  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ASGI \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <em>uvicorn main:app &#8212;reload<\/em>, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<pre><code class=\"python\">from typing import Union from fastapi import FastAPI from starlette.responses import JSONResponse from pydantic import BaseModel   class Item(BaseModel):     name: str     description: Union[str, None] = None     price: float     tax: Union[float, None] = None   app = FastAPI()   @app.post(\"\/items\/{item_id}\") async def create_item(item: Item, item_id: int):     return JSONResponse({\"item\": item.dict(), \"item_id\": item_id})  @app.get(\"\/\") async def homepage():     return JSONResponse({'hello': 'world'})  @app.get(\"\/get_items\/{item_id}\") async def read_item(item_id: int):     print(\"item_id\", item_id)     return {\"item_id\": item_id} <\/code><\/pre>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u043e\u0443\u0442\u044b \u0441 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0443\u0442\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0438\u043f\u0430\u043c, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u0431\u0443\u0434\u044c \u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0442\u0438\u043f\u044b \u0438\u0437 typing \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 pydantic, \u0447\u0442\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 FastApi, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439 <strong>endpoint <\/strong>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>GET<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441 \u043f\u0443\u0442\u0435\u043c <strong>\u201c\/items\u201d<\/strong>. \u0418 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <strong>Response<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043b\u044f ASGI \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0442\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435, \u0432\u0435\u0434\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c, \u0442\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0434\u043e\u0445\u043e\u0434\u044f \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043b\u0438\u0437\u043a\u043e\u0439 \u043a FastAPI. \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0440\u0430\u0437\u0443, \u043c\u043d\u043e\u0433\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u043e \u0438\u0434\u044f \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c.<\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c myfastapi<\/h2>\n<h3>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0430\u043b\u043e\u0433\u043e \u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e &#8212; \u043a\u043b\u0430\u0441\u0441 FastApi. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.<\/h3>\n<p>\u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f FastAPI, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c:  <\/p>\n<pre><code class=\"python\">app = FastAPI()<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u0431\u0430\u0433\u0433\u0438\u043d\u0433 \u0438 OpenAPI \u0437\u0434\u0435\u0441\u044c, \u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434 __init__ \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>myfastapi::applications::FastApi::__init__<\/strong>  <\/p>\n<pre><code class=\"python\">from typing import Callable from starlette import Starlette from myfastapi.routing import ApiRouter   class FastApi(Starlette):     def __init__(         self,         version: str = \"0.1.0\"     ) -> None:         self.version = version   self.router: APIRouter = APIRouter()<\/code><\/pre>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.  <\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <strong>ApiRouter<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <strong>FastApi<\/strong> \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Starlette<\/strong>, \u0438 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e <strong>Starlette<\/strong>, \u0430 <strong>FastAPI<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u043d\u0430\u0434 \u043d\u0438\u043c, \u043d\u043e \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <strong>get<\/strong> \u0438 <strong>post<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432.  <\/p>\n<p><strong>myfastapi::applications::FastApi::get<\/strong>  <\/p>\n<pre><code class=\"python\">def get(         self,         path: str, ) -> Callable[..., Any]:         return self.router.get(path)<\/code><\/pre>\n<p><strong>myfastapi::applications::FastApi::post<\/strong><\/p>\n<pre><code class=\"python\">def post(         self,         path: str, ) -> Callable[..., Any]:         return self.router.post(path)<\/code><\/pre>\n<p>\u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 FastApi, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRouter<\/strong>.  <\/p>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 <em>endpoint<\/em>.  <\/p>\n<p>\u0421\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043f\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0443\u043a\u0430\u0437\u0430\u043d \u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>self.router.post(path)<\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u041c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>ApiRouter<\/strong> \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u043e.  <\/p>\n<p>\u0422\u0430\u043a, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0431\u044b\u043b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u043b \u043c\u0435\u0442\u043e\u0434 <strong>__call__<\/strong>, \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 Scope, Receive, Send. \u0413\u0434\u0435 Scope \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0443\u0442\u0438, Receive \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 Send \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0438 json \u043e\u0442\u0432\u0435\u0442\u0430.  <\/p>\n<p><strong>myfastapi::applications::FastApi::__call__<\/strong>  <\/p>\n<pre><code class=\"python\">async def __call__( self, scope: Scope, receive: Receive, send: Send ) -> None:         await super().__call__(scope, receive, send)<\/code><\/pre>\n<p>\u0410\u0433\u0430. \u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <strong>Starlette<\/strong>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>get<\/strong> \u0438 <strong>post<\/strong>, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0442\u043e \u043a\u043b\u0430\u0441\u0441 FastApi \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 myfastapi, \u0433\u043e\u0442\u043e\u0432. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<p><strong>myfastapi::applications::FastApi<\/strong><\/p>\n<pre><code class=\"python\">from typing import Callable from starlette import Starlette from myfastapi.routing import APIRouter   class FastApi(Starlette):     def __init__(         self,         version: str = \"0.1.0\"     ) -> None:         self.version = version     def get(         self,         path: str,     ) -> Callable[..., Any]:         return self.router.get(path)     def post(         self,         path: str,     ) -> Callable[..., Any]:         return self.router.post(path)          async def __call__(         self, scope: Scope, receive: Receive, send: Send     ) -> None:         await super().__call__(scope, receive, send)<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043d\u043e, \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e FastApi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b <strong>routing.py<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRouter<\/strong> \u0438 <strong>ApiRoute<\/strong>. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0443 \u043d\u0438\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. ApiRouter \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0440\u043e\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRoute<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0443\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 <strong>endpoint<\/strong> \u0435\u0441\u043b\u0438 \u043f\u0443\u0442\u044c \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439, \u0438 \u043f\u043e \u0438\u0442\u043e\u0433\u0443, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0440\u043e\u0443\u0442\u044b \u0438\u043b\u0438 <strong>ApiRoute<\/strong>\u2019s \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u0443\u0442\u043e\u0432, \u0432 \u043a\u043b\u0430\u0441\u0441 <strong>Router<\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <em>starlette<\/em>. \u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 FastApi \u0441 \u0440\u043e\u0443\u0442\u0430\u043c\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0410 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445, \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0443 <strong>ApiRoute<\/strong> \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u043e\u0443\u0442\u043e\u0432 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <em>starlette<\/em>.  <\/p>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c, \u0438 \u0432\u0441\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e. <strong>ApiRouter<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0440\u043e\u0443\u0442\u043e\u0432 \u043a \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 starlette \u043a\u043b\u0430\u0441\u0441\u0435 <strong>Routing<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <strong>ApiRoute<\/strong> \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0443\u0442\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c <strong>ApiRoute<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u043e\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>ApiRouter<\/strong> \u043c\u044b \u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <strong>Router<\/strong> \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f, \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <strong>ApiRoute<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043a\u043b\u0430\u0441\u0441\u0430, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p><strong>myfastapi::routing::ApiRouter<\/strong><\/p>\n<pre><code class=\"python\">from typing import Callable from starlette.routing import Router, Any   class APIRouter(Router):     def __init__(self) -> None:         super().__init__()         self.route_class = ApiRoute<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>self.add_api_route<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <strong>@app.post(&#171;\/items\/&#187;)<\/strong>, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 <strong>endpoint<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">async def create_item(item: Item):     return JSONResponse(item.dict())<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRoute<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>self.route_class<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <em>self.routes<\/em>, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <strong>Routing <\/strong>(<strong>starlette<\/strong>).  <\/p>\n<p><strong>myfastapi::routing::ApiRouter::add_api_route<\/strong><\/p>\n<pre><code class=\"python\">def add_api_route(         self,         path: str,         endpoint: Callable[..., Any],   method: str ) -> None: route = self.route_class(     path,      endpoint=endpoint,      method=method ) self.routes.append(route)<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <strong>post<\/strong> \u0438 <strong>get <\/strong>(\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435?).  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>FastApi<\/strong>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p><strong>myfastapi::applications::FastApi::get<\/strong><\/p>\n<pre><code class=\"python\">def get(       self,       path: str, ) -> Callable[..., Any]:       return self.router.get(path)<\/code><\/pre>\n<p>\u0418 \u043a\u0430\u043a \u0432\u044b \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<p><strong>myfastapi::routing::ApiRouter::get<\/strong><\/p>\n<pre><code class=\"python\">def get(self, path: str) -> Callable[[Callable[..., Any]], [Callable[..., Any]]:         def decorator(func: [Callable[..., Any]) -> [Callable[..., Any]:       self.add_api_route(path, func, method=\u201dget\u201d) return func   return decorator<\/code><\/pre>\n<p>\u041d\u0438\u0447\u0435\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u0433\u0434\u0435 func \u044d\u0442\u043e \u043d\u0430\u0448 <strong>endpoint<\/strong> \u0434\u043b\u044f <strong>get<\/strong> \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0432 \u043c\u0435\u0442\u043e\u0434 <em>self.add_api_route<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432\u044b\u0448\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0438 \u0440\u043e\u0443\u0442\u044b \u0432 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.  <\/p>\n<p>\u0418 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <strong>post<\/strong>  <\/p>\n<p><strong>myfastapi::routing::ApiRouter::post<\/strong><\/p>\n<pre><code class=\"python\">def post(self, path: str) -> Callable[[Callable[..., Any]], [Callable[..., Any]]:         def decorator(func: [Callable[..., Any]) -> [Callable[..., Any]:       self.add_api_route(path, func, method=\u201dpost\u201d) return func   return decorator<\/code><\/pre>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0438 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0445\u043e\u0442\u044f \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u0442\u044c \u044d\u0442\u043e \u0432\u0432\u0438\u0434\u0443.  <\/p>\n<p>\u041d\u0443 \u0430 \u0441\u0435\u0439\u0447\u0430\u0441, \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0435\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043a\u043b\u0430\u0441\u0441:<\/p>\n<p><strong>myfastapi::routing::ApiRouter<\/strong><\/p>\n<pre><code class=\"python\">from typing import Callable from starlette.routing import Router, Any   class APIRouter(Router):     def __init__(self) -> None:         super().__init__()         self.route_class = ApiRoute      def add_api_route(         self,         path: str,         endpoint: Callable[..., Any],   method: str ) -> None: route = self.route_class(     path,      endpoint=endpoint,      method=method ) self.routes.append(route)      def get(self, path: str) -> Callable[[Callable[..., Any]], [Callable[..., Any]]:         def decorator(func: [Callable[..., Any]) -> [Callable[..., Any]:       self.add_api_route(path, func, method=\u201dget\u201d) return func   return decorator       def post(self, path: str) -> Callable[[Callable[..., Any]], [Callable[..., Any]]:         def decorator(func: [Callable[..., Any]) -> [Callable[..., Any]:       self.add_api_route(path, func, method=\u201dpost\u201d) return func   return decorator<\/code><\/pre>\n<p>\u0414\u0430, \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u0438 \u0443\u0436\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <strong>ApiRoute<\/strong>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 starlette \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Route<\/strong>. \u0418 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043d\u0430\u043c \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u043e\u0439, \u0430 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0412\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 FastApi \u0434\u0435\u043b\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0442\u0438\u043f\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 Starlette \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0441\u0432\u043e\u0435\u0439 \u043e\u0441\u043d\u043e\u0432\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 Starlette \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u043c\u0435\u0441\u0442\u043e FastApi, \u0442\u043e \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043b\u044e\u0431\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0438\u043c \u0442\u0438\u043f\u044b, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043f\u0440\u0438\u0439\u0442\u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441. FastApi \u0436\u0435 \u0432\u044b\u0434\u0430\u0441\u0442 \u0432\u0430\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0430\u043c\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430\u0447\u043d\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435.  <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044f \u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0439\u0447\u0430\u0441.  <\/p>\n<p><strong>myfastapi::routing::ApiRoute<\/strong>  <\/p>\n<pre><code class=\"python\">from starlette.routing import request_response   class ApiRoute(routing.Router):     def __init__(         self,         path: str,         endpoint: Callable[..., Any],         method: str     ) -> None:         self.path = path         self.endpoint = endpoint         self.method = method         assert callable(endpoint), \"An endpoint must be a callable\"         self.dependant = get_dependant(path=self.path, call=self.endpoint)         self.app = request_response(get_request_handler())<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>ApiRoute<\/strong> \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0433\u0434\u0435 <strong>get_dependant<\/strong> \u043a\u043b\u044e\u0447\u0435\u0432\u0430\u044f \u0434\u043b\u044f \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0435 \u0432\u044b\u0437\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0443\u0442\u0438, \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0442\u0435\u043b\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0442\u0438\u043f\u044b, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435\u0442. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, FastApi \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u043a\u0430\u0436\u0438\u0442\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u0442\u0438\u043f Optional \u0438\u0437 typing, \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <strong>get_dependant<\/strong>, \u0430 \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>self.app<\/strong> \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u0441\u043b\u0435.  <\/p>\n<p><strong>myfastapi::dependencies::utils::get_dependant<\/strong> <\/p>\n<pre><code class=\"python\">def get_dependant(     *,     path: str,     call: Callable[..., Any], ) -> None:     path_param_names = get_path_param_names(path)     endpoint_signature = inspect.signature(call)     signature_params = endpoint_signature.parameters     dependant = Dependant(call=call, path=path)     for param_name, param in signature_params.items():         param_field = get_param_field(             param=param, param_name=param_name         )         if param_name in path_param_names: dependant.path_params.append(param_field)         elif (lenient_issubclass(param_field.type_, (list, set, tuple, dict)) or         lenient_issubclass(param_field.type_, BaseModel)         ): dependant.body_params.append(param_field)         else: dependant.query_params.append(param_field)<\/code><\/pre>\n<p>\u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. <strong>get_dependant<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u0438 <strong>endpoint <\/strong>\u0437\u0430\u043f\u0440\u043e\u0441\u0430. <strong>get_path_param_names<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u043c\u0435\u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0443\u0442\u0438:<\/p>\n<p><strong>myfastapi::utils::get_path_param_names<\/strong><\/p>\n<pre><code class=\"python\">def get_path_param_names(path: str) -> Set[str]:     return set(re.findall(\"{(.*?)}\", path))<\/code><\/pre>\n<p><strong>inspect.signature<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c, \u0442\u0438\u043f\u043e\u043c \u0438 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u041a\u043b\u0430\u0441\u0441 <strong>Dependant<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<p><strong>myfastapi::dependencies::models::Dependant<\/strong>  <\/p>\n<pre><code class=\"python\">from typing import Any, Callable, List, Optional from pydantic.fields import ModelField   class Dependant:     def __init__(         self,         *,         path_params: Optional[List[ModelField]] = None,         query_params: Optional[List[ModelField]] = None,         body_params: Optional[List[ModelField]] = None,         call: Optional[Callable[..., Any]] = None,         path: Optional[str] = None     ) -> None:         self.path_params = path_params or []         self.query_params = query_params or []         self.body_params = body_params or []         self.call = call         self.path = path<\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ModelField<\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pydantic. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 FastApi \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043e\u043d \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 pydantic, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 FastApi \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pydantic. \u0418\u043c\u0435\u043d\u043d\u043e \u043c\u044b \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 <strong>ModelField<\/strong>.  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a <strong>get_dependant<\/strong>, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <strong>endpoint<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0446\u0438\u043a\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ModelField<\/strong><\/p>\n<pre><code class=\"python\">param_field = get_param_field(             param=param, param_name=param_name         )<\/code><\/pre>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u0432\u044b\u044f\u0432\u043b\u044f\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 <strong>Dependant<\/strong>:<\/p>\n<pre><code class=\"python\">if param_name in path_param_names: dependant.path_params.append(param_field) elif (lenient_issubclass(param_field.type_, (list, set, tuple, dict)) or         lenient_issubclass(param_field.type_, BaseModel) ): dependant.body_params.append(param_field) else: dependant.query_params.append(param_field)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>get_param_field<\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <strong>ModelField<\/strong> \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p><strong>myfastapi::dependencies::utils::get_param_field<\/strong><\/p>\n<pre><code class=\"python\">from pydantic import BaseConfig from pydantic.fields import ModelField, Undefined    def get_param_field(     param: inspect.Parameter,     param_name: str ) -> ModelField:     default_value: Any = Undefined     if not param.default == param.empty: default_value = param.default     required = True     if default_value is not Undefined: required = False     annotation: Any = Any     if not param.annotation == param.empty:         annotation = param.annotation     field = ModelField(         name=param_name,         type_=annotation,         default=default_value,         class_validators=None,         required=required,         model_config=BaseConfig,     )           return field<\/code><\/pre>\n<p>\u0412 <strong>get_param_field<\/strong> \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u0430\u043a \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c <strong>ModelField<\/strong> \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.  <\/p>\n<p>\u041f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435, \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Dependant<\/strong> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<pre><code class=\"python\">if param_name in path_param_names: dependant.path_params.append(param_field) elif (lenient_issubclass(param_field.type_, (list, set, tuple, dict)) or         lenient_issubclass(param_field.type_, BaseModel) ): dependant.body_params.append(param_field) else: dependant.query_params.append(param_field)<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432 <strong>path_param_names<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0443\u0442\u0438, \u0442\u043e \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 path_params, \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0438\u043b\u0438 BaseModel \u043e\u0442 pydantic, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">class Item(BaseModel):     name: str     description: Union[str, None] = None     price: float     tax: Union[float, None] = None<\/code><\/pre>\n<p>\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <em>body_params<\/em>, \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0438 \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0443\u0442\u0438, \u043d\u0438 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u043e \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 <em>query_params<\/em> \u0438 \u0440\u0430\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0443\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u201c?\u201d \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435.  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041d\u0430\u0448\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u044b, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 <em>&#8212;reload<\/em>. \u041e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u0434\u0435\u0442\u044c \u0438 \u0436\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u043b <strong>endpoint<\/strong> \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0443\u0442\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 <strong>Dependant<\/strong> \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f.  <\/p>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>ApiRoute<\/strong>:<\/p>\n<p><strong>myfastapi::routing::ApiRoute<\/strong> <\/p>\n<pre><code class=\"python\">from starlette.routing import request_response   class ApiRoute(routing.Router):     def __init__(         self,         path: str,         endpoint: Callable[..., Any],         method: str     ) -> None:         self.path = path         self.endpoint = endpoint         self.method = method         assert callable(endpoint), \"An endpoint must be a callable\"         self.dependant = get_dependant(path=self.path, call=self.endpoint)         self.app = request_response(get_request_handler(dependant=self.dependant))<\/code><\/pre>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0442\u043e, \u043e \u0447\u0435\u043c \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e uvicorn \u043d\u0443\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"python\">async def app(scope, receive, send):     \"\"\"     Echo the request body back in an HTTP response.     \"\"\"     body = await read_body(receive)     await send({         'type': 'http.response.start',         'status': 200,         'headers': [             [b'content-type', b'text\/plain'],         ]     })     await send({         'type': 'http.response.body',         'body': body,     }) <\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 &#8212; <em>scope, receive, send<\/em>. \u0413\u0434\u0435 scope \u044d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u0443\u0442\u044c, receive \u044d\u0442\u043e \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 send \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<p>\u041d\u043e \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0449\u0435\u0439 FastApi \u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043d\u0443\u043b\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u0435\u043c\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f starlette, \u043d\u0430\u043c, \u0447\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 FastApi, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b.  <\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRoute<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>request_response<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u044f\u0441\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 request, \u0438 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 response, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 request \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Request<\/strong> \u043e\u0442 starlette, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 response, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <strong>__call__<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0440\u0438 ASGI \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <strong>await send<\/strong> \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f starlette \u0443\u0436\u0435 \u0435\u0441\u0442\u044c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441 <strong>Response<\/strong>.     <\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>get_request_handler<\/strong>:<\/p>\n<pre><code class=\"python\">self.app = request_response(get_request_handler(dependant=self.dependant))<\/code><\/pre>\n<p>\u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043d\u0435\u0435.  <\/p>\n<p><strong>myfastapi::routing::get_request_handler<\/strong>  <\/p>\n<pre><code class=\"python\">def get_request_handler(     dependant: Dependant, ) -> Callable[[Request], Coroutine[Any, Any, Response]]:     is_coroutine = asyncio.iscoroutinefunction(dependant.call)     async def app(request: Request) -> Response:   body = None         if dependant.body_params:             body = await request.json()             \u0431\u0443\u0434\u0443       solved_result = await solve_dependencies(             request=request,             dependant=dependant,             body=body             )         values, errors = solved_result         if errors: raise ValidationError(errors, RequestErrorModel)          raw_response = await run_endpoint_function(                 dependant=dependant, values=values, is_coroutine=is_coroutine             )         if isinstance(raw_response, Response): return raw_response   if isinstance(raw_response, (dict, str, int, float, type(None))):             return JSONResponse(raw_response)         else: raise Exception(\"Type of response is not supported yet.\")      return app<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, <strong>get_request_handler<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 dependant \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c <strong>endpoint<\/strong> \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>call<\/strong> \u0443 <strong>dependant<\/strong>.   <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>app<\/strong> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0440\u043e\u0443\u0442\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>json<\/strong> \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Request<\/strong> \u043e\u0442 starlette, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>solve_dependencies<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b <strong>endpoint<\/strong> \u0438 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u0440\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0448\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <strong>run_endpoint<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 endpoint, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <strong>response<\/strong>. \u0414\u0430\u043d\u043d\u044b\u0439 <strong>response<\/strong> \u043a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c ASGI \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0442\u0432\u0435\u0442. \u0418 \u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0432 \u043d\u0430\u0448 \u043e\u0442\u0432\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <strong>JsonResponse<\/strong> \u043e\u0442 starlette.  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <strong>solve_dependencies<\/strong>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u043a\u0430\u043a \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.  <\/p>\n<p><strong>myfastapi::dependencies::utils::solve_dependencies<\/strong>  <\/p>\n<pre><code class=\"python\">async def solve_dependencies(     *,     request: Request,     dependant: Dependant,     body: Dict[str, Any], ) -> Tuple[Dict[str, Any], List[ErrorWrapper], Response]:     values: Dict[str, any] = {}     errors: List[ErrorWrapper] = []        path_values, path_errors = request_params_to_args(         dependant.path_params, request.path_params     )     query_values, query_errors = request_params_to_args(         dependant.query_params, request.query_params     )     values.update(path_values)     values.update(query_values)     errors += path_errors + query_errors      if dependant.body_params:         (             body_values,             body_errors,         ) = await request_body_to_args(  # body_params checked above             required_params=dependant.body_params, received_body=body         )         values.update(body_values)         errors.extend(body_errors)     return values, errors<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>dependant<\/strong>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0432\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>request_params_to_args<\/strong> \u0438 <strong>request_body_to_args<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Dependant<\/strong> \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ModelField<\/strong> \u043e\u0442 pydantic, \u043c\u0430\u0433\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0438\u0437 <strong>scope<\/strong> \u043a\u043b\u0430\u0441\u0441\u043e\u043c <strong>Request<\/strong> \u043e\u0442 starlette, \u0438 body, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u043b\u0438 \u0432 <strong>get_request_handler<\/strong>.  <\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430 <strong>request_params_to_args<\/strong>  <\/p>\n<p><strong>myfastapi::dependencies::utils::request_params_to_args<\/strong>  <\/p>\n<pre><code class=\"python\">from pydantic.error_wrappers import ErrorWrapper from pydantic.errors import MissingError    def request_params_to_args(     required_params: Sequence[ModelField],     recieved_params: Union[Mapping[str, Any], QueryParams] ) -> Tuple[Dict[str, Any], List[ErrorWrapper]]:     values: Dict[str, Any] = {}     errors: List[ErrorWrapper] = []     for field in required_params:         value = recieved_params.get(field.alias)         if value is None:             if field.required:                 errors.append(ErrorWrapper(                     MissingError(),                     loc=field.alias)                     )             else: values[field.name] = deepcopy(field.default)             continue          v_, errors_ = field.validate(value, values, loc=field.alias)          if isinstance(errors_, ErrorWrapper):             errors.append(errors_)         elif isinstance(errors_, list):             errors.extend(errors_)         else:             values[field.name] = v_     return values, errors<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u043c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f <strong>endpoint<\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>alias<\/strong>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439, \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435\u0442\u0443 \u0438 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0448\u0438\u0431\u043e\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>MissingError<\/strong>, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0442, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0446\u0438\u043a\u043b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0435\u0441\u0442\u044c, \u0442\u043e, \u0445\u0440\u0430\u043d\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0432\u0438\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ModelField<\/strong> \u043e\u0442 pydantic, \u043d\u0430\u043c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <strong>validate<\/strong> \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0440\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 \u043f\u0440\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>request_params_to_args<\/strong>, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0443\u0442\u0438 \u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"python\">    path_values, path_errors = request_params_to_args(         dependant.path_params, request.path_params     )     query_values, query_errors = request_params_to_args(         dependant.query_params, request.query_params     )     values.update(path_values)     values.update(query_values)     errors += path_errors + query_errors<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043e\u0445\u043e\u0436\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>request_body_to_args<\/strong>.<\/p>\n<p><strong>myfastapi::dependencies::utils::request_body_to_args<\/strong> <\/p>\n<pre><code class=\"python\">async def request_body_to_args(     required_params: List[ModelField],     received_body: Union[Dict[str, any], None], ) -> Tuple[Dict[str, any], List[ErrorWrapper]]:     values: Dict[str, Any] = {}     errors: List[ErrorWrapper] = []     if required_params:         field_alias_omitted = len(required_params)         if field_alias_omitted == 1:             field = required_params[0]             received_body = {field.alias: received_body}                for field in required_params:             if field_alias_omitted:                 loc = (\"body\",)             else:                 loc = (\"body\", field.alias)             value: Optional[Any] = None             if received_body is not None:                 try: value = received_body.get(field.alias)                 except AttributeError:                     errors.append(ErrorWrapper(MissingError(), loc=loc))                     continue             if value is None:                 if field.required: errors.append(ErrorWrapper(MissingError(), loc=loc))                 else: values[field.name] = deepcopy(field.default)                 continue              v_, errors_ = field.validate(value, values, loc=loc)              if isinstance(errors_, ErrorWrapper):                 errors.append(errors_)             elif isinstance(errors_, list):                 errors.extend(errors_)             else:                 values[field.name] = v_     return values, errors<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043a\u0430\u043a \u0438 \u0432 <strong>request_params_to_args<\/strong>, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0432 \u0442\u0435\u043b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0438 \u0438\u0434\u0435\u043c \u0446\u0438\u043a\u043b\u0430\u043c \u043f\u043e \u043d\u0438\u043c.  <\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>request_body_to_args<\/strong>, \u0435\u0441\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a <strong>body_params<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Dependant<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b <strong>endpoint<\/strong>, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u0443\u0441\u0442\u044b\u043c.  <\/p>\n<pre><code class=\"python\">if dependant.body_params:         (             body_values,             body_errors,         ) = await request_body_to_args(  # body_params checked above             required_params=dependant.body_params, received_body=body         )         values.update(body_values)         errors.extend(body_errors)     return values, errors<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>get_request_handler<\/strong> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">  solved_result = await solve_dependencies(               request=request,               dependant=dependant,               body=body               )   values, errors = solved_result   if errors: raise ValidationError(errors, RequestErrorModel)      raw_response = await run_endpoint_function(           dependant=dependant, values=values, is_coroutine=is_coroutine       ) <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <strong>endpoint<\/strong> \u0440\u043e\u0443\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>run_endpoint_function<\/strong>:<\/p>\n<pre><code class=\"python\">async def run_endpoint_function(     *, dependant: Dependant, values: List[str, Any], is_coroutine: bool ) -> Any:     assert dependant.call is not None, \"dependant.call must be a function\"      if is_coroutine:         return await dependant.call(**values)     else:         return await run_in_threadpool(dependant.call, **values)<\/code><\/pre>\n<p>\u0412 \u043d\u0435\u0439 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0435\u0441\u043b\u0438 <strong>endpoint<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c await, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435\u0442, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>run_in_threadpool<\/strong> \u043e\u0442 starlette, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c <strong>endpoint<\/strong> \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044f <em>event loop<\/em>.  <\/p>\n<p>\u0418 \u0441\u0435\u0439\u0447\u0430\u0441, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0430\u0448 <strong>endpoint<\/strong> \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0438 \u0432\u0435\u0440\u043d\u0443\u043b \u043e\u0442\u0432\u0435\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<pre><code class=\"python\">if isinstance(raw_response, Response): return raw_response if isinstance(raw_response, (dict, str, int, float, type(None))):     return JSONResponse(raw_response) else: raise Exception(\"Type of response is not supported yet.\")<\/code><\/pre>\n<p>\u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u0421\u043f\u0435\u0440\u0432\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Response<\/strong> \u043e\u0442 starlette, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <strong>JSONResponse:<\/strong><\/p>\n<pre><code class=\"python\">from starlette.responses import JSONResponse<\/code><\/pre>\n<p>\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 <strong>endpoint<\/strong>  <\/p>\n<pre><code class=\"python\">@app.post(\"\/items\/{item_id}\") async def create_item(item_id: int):     return JSONResponse({\"item\": item_id})<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442, \u044d\u0442\u043e <strong>dict<\/strong> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0438\u043f, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u0432 <strong>JSONResponse<\/strong>, \u043d\u043e \u0443 FastApi \u0438\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0442\u0430\u043a, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u044d\u0442\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0430\u0441\u0441 <strong>JSONResponse<\/strong> \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c <strong>endpoint<\/strong> \u0432\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e. \u0422\u0430\u043a\u0436\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0441\u043d\u043e\u0432\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 <strong>run_endpoint_function<\/strong>, \u0442\u043e \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u0447\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0434\u0435\u043b\u0430\u044f <strong>endpoint<\/strong> \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u0432\u044b \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442, \u043f\u043e\u043d\u0438\u043c\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e FastApi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 <strong>Response<\/strong> \u043e\u0442 starlette \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0430\u0448\u0438\u0445 <strong>endpoint\u2019s<\/strong>. <\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u0442, \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 FastApi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043d\u0443\u043b\u044f. \u041d\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0441 \u043d\u0443\u043b\u044f. FastApi \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0435 \u043d\u0430 pydantic, \u043a\u0430\u043a \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 starlette.  <\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u0443\u0441\u043a\u0435 \u043a\u0443\u0434\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">from typing import Union  from myfastapi.applications import FastAPI from starlette.responses import JSONResponse from pydantic import BaseModel   class Item(BaseModel):     name: str     description: Union[str, None] = None     price: float     tax: Union[float, None] = None   app = FastAPI()   @app.post(\"\/items\/{item_id}\") async def create_item(item: Item, item_id: int):     return JSONResponse({\"item\": item.dict(), \"item_id\": item_id})  @app.get(\"\/\") async def homepage():     return JSONResponse({'hello': 'world'})  @app.get(\"\/get_items\/{item_id}\") async def read_item(item_id: int):     return {\"item_id\": item_id} <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"powershell\">uvicorn main:app --reload<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 API&#8217;s \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Postman.<\/p>\n<p><a href=\"https:\/\/github.com\/Nikitala0014\/myfastapi\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<p>\u0423\u0434\u0430\u0447\u0438!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/708678\/\"> https:\/\/habr.com\/ru\/post\/708678\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0434\u0435\u0441\u044c, \u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 FastAPI. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0439 \u0432\u0435\u0431-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f API. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ASGI-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0437\u0434\u0435\u0441\u044c \u0436\u0435 \u043c\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u043a\u043e \u0437\u0430\u0442\u0440\u043e\u043d\u0435\u043c \u0435\u0433\u043e.<\/p>\n<p>\u0418 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0432, \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u043a\u0430\u043a \u044f\u0441\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c FastAPI. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043e\u043d \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 Starlette, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 ASGI, \u0438 \u043d\u0430 Pydantic, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. FastAPI \u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438.<\/p>\n<ol>\n<li>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043f\u043e \u0438\u0442\u043e\u0433\u0443 \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c FastAPI, \u0441 \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c myfastapi.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e\u0435 \u043d\u0430 fastapi \u0441 \u043f\u043e\u043c\u043e\u0449\u044c myfastapi.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0427\u0442\u043e \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c<\/h2>\n<p>\u0412\u0441\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 FastAPI, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 Starlette, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u0440\u043e\u0443\u0442\u044b \u0432 \u043a\u043b\u0430\u0441\u0441 Starlette. \u042d\u0442\u0438 \u0440\u043e\u0443\u0442\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0442\u0430\u043c \u0434\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0445\u043e\u0441\u0442\u0443 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 FastAPI, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0441 ASGI \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <em>Scope<\/em>, <em>Receive<\/em> \u0438 <em>Send<\/em>. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e, \u0442\u043e\u0447\u043d\u0435\u0435 \u043a\u043b\u0430\u0441\u0441\u0443, \u043d\u0443\u0436\u0435\u043d \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <strong>__call__<\/strong>. \u0414\u0430\u043d\u043d\u044b\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 FastAPI \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438\u0448\u044c \u0432 \u0432\u0438\u0434\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <strong>super().__call__<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430 Starlette. \u041d\u043e \u043f\u043e\u043a\u0430 Starlette \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442, \u0434\u043e \u043d\u0435\u0433\u043e \u043c\u044b \u0435\u0449\u0435 \u0434\u043e\u0439\u0434\u0435\u043c.  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ASGI \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <em>uvicorn main:app &#8212;reload<\/em>, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/p>\n<pre><code class=\"python\">from typing import Union from fastapi import FastAPI from starlette.responses import JSONResponse from pydantic import BaseModel   class Item(BaseModel):     name: str     description: Union[str, None] = None     price: float     tax: Union[float, None] = None   app = FastAPI()   @app.post(\"\/items\/{item_id}\") async def create_item(item: Item, item_id: int):     return JSONResponse({\"item\": item.dict(), \"item_id\": item_id})  @app.get(\"\/\") async def homepage():     return JSONResponse({'hello': 'world'})  @app.get(\"\/get_items\/{item_id}\") async def read_item(item_id: int):     print(\"item_id\", item_id)     return {\"item_id\": item_id} <\/code><\/pre>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u043e\u0443\u0442\u044b \u0441 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0443\u0442\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0438\u043f\u0430\u043c, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u0431\u0443\u0434\u044c \u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0442\u0438\u043f\u044b \u0438\u0437 typing \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 pydantic, \u0447\u0442\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 FastApi, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.\u00a0<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439 <strong>endpoint <\/strong>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>GET<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441 \u043f\u0443\u0442\u0435\u043c <strong>\u201c\/items\u201d<\/strong>. \u0418 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <strong>Response<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043b\u044f ASGI \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0442\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435, \u0432\u0435\u0434\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c, \u0442\u043e \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0434\u043e\u0445\u043e\u0434\u044f \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u043b\u0438\u0437\u043a\u043e\u0439 \u043a FastAPI. \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u043e\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0440\u0430\u0437\u0443, \u043c\u043d\u043e\u0433\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043d\u043e \u0438\u0434\u044f \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c.<\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c myfastapi<\/h2>\n<h3>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043c\u0430\u043b\u043e\u0433\u043e \u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e &#8212; \u043a\u043b\u0430\u0441\u0441 FastApi. \u0414\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.<\/h3>\n<p>\u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f FastAPI, \u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u043e\u043c:  <\/p>\n<pre><code class=\"python\">app = FastAPI()<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0435\u0431\u0430\u0433\u0433\u0438\u043d\u0433 \u0438 OpenAPI \u0437\u0434\u0435\u0441\u044c, \u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434 __init__ \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>myfastapi::applications::FastApi::__init__<\/strong>  <\/p>\n<pre><code class=\"python\">from typing import Callable from starlette import Starlette from myfastapi.routing import ApiRouter   class FastApi(Starlette):     def __init__(         self,         version: str = \"0.1.0\"     ) -> None:         self.version = version   self.router: APIRouter = APIRouter()<\/code><\/pre>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0434\u0435\u0441\u044c.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 &#8212; \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b.  <\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <strong>ApiRouter<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.  <\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 <strong>FastApi<\/strong> \u043d\u0435 \u0442\u0430\u043a\u043e\u0439 \u0443\u0436 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Starlette<\/strong>, \u0438 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u044e \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e <strong>Starlette<\/strong>, \u0430 <strong>FastAPI<\/strong> \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u0430 \u043d\u0430\u0434 \u043d\u0438\u043c, \u043d\u043e \u0441 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <strong>get<\/strong> \u0438 <strong>post<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432.  <\/p>\n<p><strong>myfastapi::applications::FastApi::get<\/strong>  <\/p>\n<pre><code class=\"python\">def get(         self,         path: str, ) -> Callable[..., Any]:         return self.router.get(path)<\/code><\/pre>\n<p><strong>myfastapi::applications::FastApi::post<\/strong><\/p>\n<pre><code class=\"python\">def post(         self,         path: str, ) -> Callable[..., Any]:         return self.router.post(path)<\/code><\/pre>\n<p>\u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 FastApi, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0434 \u0441\u043e\u0431\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRouter<\/strong>.  <\/p>\n<p>\u0412\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 <em>endpoint<\/em>.  <\/p>\n<p>\u0421\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043f\u043e \u0442\u043e\u043c\u0443, \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0443\u043a\u0430\u0437\u0430\u043d \u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0437\u043e\u0432 <strong>self.router.post(path)<\/strong> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440. \u041c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>ApiRouter<\/strong> \u0443\u0436\u0435 \u0441\u043a\u043e\u0440\u043e.  <\/p>\n<p>\u0422\u0430\u043a, \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 ASGI \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0431\u044b\u043b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043c\u0435\u043b \u043c\u0435\u0442\u043e\u0434 <strong>__call__<\/strong>, \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 Scope, Receive, Send. \u0413\u0434\u0435 Scope \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0443\u0442\u0438, Receive \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0442\u0435\u043b\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 Send \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0438 json \u043e\u0442\u0432\u0435\u0442\u0430.  <\/p>\n<p><strong>myfastapi::applications::FastApi::__call__<\/strong>  <\/p>\n<pre><code class=\"python\">async def __call__( self, scope: Scope, receive: Receive, send: Send ) -> None:         await super().__call__(scope, receive, send)<\/code><\/pre>\n<p>\u0410\u0433\u0430. \u041e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <strong>Starlette<\/strong>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>get<\/strong> \u0438 <strong>post<\/strong>, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0442\u043e \u043a\u043b\u0430\u0441\u0441 FastApi \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 myfastapi, \u0433\u043e\u0442\u043e\u0432. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<p><strong>myfastapi::applications::FastApi<\/strong><\/p>\n<pre><code class=\"python\">from typing import Callable from starlette import Starlette from myfastapi.routing import APIRouter   class FastApi(Starlette):     def __init__(         self,         version: str = \"0.1.0\"     ) -> None:         self.version = version     def get(         self,         path: str,     ) -> Callable[..., Any]:         return self.router.get(path)     def post(         self,         path: str,     ) -> Callable[..., Any]:         return self.router.post(path)          async def __call__(         self, scope: Scope, receive: Receive, send: Send     ) -> None:         await super().__call__(scope, receive, send)<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043d\u043e, \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e FastApi \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0439\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b <strong>routing.py<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRouter<\/strong> \u0438 <strong>ApiRoute<\/strong>. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0443 \u043d\u0438\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. ApiRouter \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0440\u043e\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRoute<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0443\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u044b\u0437\u043e\u0432\u0430 <strong>endpoint<\/strong> \u0435\u0441\u043b\u0438 \u043f\u0443\u0442\u044c \u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439, \u0438 \u043f\u043e \u0438\u0442\u043e\u0433\u0443, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0440\u043e\u0443\u0442\u044b \u0438\u043b\u0438 <strong>ApiRoute<\/strong>\u2019s \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u0443\u0442\u043e\u0432, \u0432 \u043a\u043b\u0430\u0441\u0441 <strong>Router<\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <em>starlette<\/em>. \u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 FastApi \u0441 \u0440\u043e\u0443\u0442\u0430\u043c\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0410 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445, \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0443 <strong>ApiRoute<\/strong> \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u043e\u0443\u0442\u043e\u0432 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <em>starlette<\/em>.  <\/p>\n<p>\u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c, \u0438 \u0432\u0441\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e. <strong>ApiRouter<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0440\u043e\u0443\u0442\u043e\u0432 \u043a \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 starlette \u043a\u043b\u0430\u0441\u0441\u0435 <strong>Routing<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u043c <strong>ApiRoute<\/strong> \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u0443\u0442\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0441\u0430\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c <strong>ApiRoute<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u043e\u043b\u043e\u0447\u043a\u043e\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>ApiRouter<\/strong> \u043c\u044b \u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <strong>Router<\/strong> \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f, \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 <strong>ApiRoute<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043a\u043b\u0430\u0441\u0441\u0430, \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  <\/p>\n<p><strong>myfastapi::routing::ApiRouter<\/strong><\/p>\n<pre><code class=\"python\">from typing import Callable from starlette.routing import Router, Any   class APIRouter(Router):     def __init__(self) -> None:         super().__init__()         self.route_class = ApiRoute<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <strong>self.add_api_route<\/strong> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <strong>@app.post(&#171;\/items\/&#187;)<\/strong>, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 <strong>endpoint<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">async def create_item(item: Item):     return JSONResponse(item.dict())<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>ApiRoute<\/strong>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>self.route_class<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043f\u0438\u0441\u043e\u043a <em>self.routes<\/em>, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0439\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <strong>Routing <\/strong>(<strong>starlette<\/strong>).  <\/p>\n<p><strong>myfastapi::routing::ApiRouter::add_api_route<\/strong><\/p>\n<pre><code class=\"python\">def add_api_route(         self,         path: str,         endpoint: Callable[..., Any],   method: str ) -> None: route = self.route_class(     path,      endpoint=endpoint,      method=method ) self.routes.append(route)<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <strong>post<\/strong> \u0438 <strong>get <\/strong>(\u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435?).  <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <strong>FastApi<\/strong>, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p><strong>myfastapi::applications::FastApi::get<\/strong><\/p>\n<pre><code class=\"python\">def get(       self,       path: str, ) -> Callable[..., Any]:       return self.router.get(path)<\/code><\/pre>\n<p>\u0418 \u043a\u0430\u043a \u0432\u044b \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0435\u0441\u044c, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<p><strong>myfastapi::routing::ApiRouter::get<\/strong><\/p>\n<pre><code class=\"python\">def get(self, path: str) -> Callable[[Callable[..., Any]], [Callable[...,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-343367","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343367"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343367\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}