コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 9 of about 9 for APIRouter (0.004 sec.)
Bigger Applications - Multiple Files 12924
Bigger Applications - Multiple Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you are building an application or a web API, it's rarely the case that you ... ── __init__.py # makes "internal" a "Python subpackage" │ └── admin.py # "admin" submodule, e.g. import app.internal.admin APIRouter Let's say the file dedicated to handling just users is the submodule at /app/routers/users.py . You want to have the path ... API application/web API (it's part of the same "Python Package"). You can create the path operations for that module using APIRouter . Import APIRouter You import it and create an "instance" the same way you would with the class FastAPI : app/routers/user ... s.py from fastapi import APIRouter router = APIRouter () @router . get ( "/users/" , tags = [ "users" ]) async def read_users (): return [{ "username" : "Ric ...
https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
APIRouter class 11144
APIRouter class Here's the reference information for the APIRouter class, with all its parameters, attributes and methods. You can import the APIRouter class directly from fastapi : from fastapi import APIRouter ::: fastapi.APIRouter option ...
https://man.mtool.work/fastapi/0.115/reference/apirouter/
OpenAPI Callbacks 9652
OpenAPI Callbacks Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You could create an API with a path operation that could trigger a request to an external API cre ... tty normal, most of the code is probably already familiar to you: Python 3.8+ from typing import Union from fastapi import APIRouter , FastAPI from pydantic import BaseModel , HttpUrl app = FastAPI () class Invoice ( BaseModel ): id : str title : Union [ ... BaseModel ): description : str paid : bool class InvoiceEventReceived ( BaseModel ): ok : bool invoices_callback_router = APIRouter () @invoices_callback_router . post ( "{$callback_url}/invoices/{$request.body.id}" , response_model = InvoiceEventReceive ... e to put the parameters, the Pydantic model for the body, for the response, etc. for that external API . Create a callback APIRouter First create a new APIRouter that will contain one or more callbacks. Python 3.8+ from typing import Union from fastapi im ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-callbacks/
Custom Request and APIRoute class 8538
Custom Request and APIRoute class Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some cases, you may want to override the logic used by the Request and APIRout ... nt ] = Body ()): return sum ( numbers ) Custom APIRoute class in a router You can also set the route_class parameter of an APIRouter : Python 3.8+ import time from typing import Callable from fastapi import APIRouter , FastAPI , Request , Response from fa ... "route response headers: { response . headers } " ) return response return custom_route_handler app = FastAPI () router = APIRouter ( route_class = TimedRoute ) @app . get ( "/" ) async def not_timed (): return { "message" : "Not timed" } @router . get ( ... se with the time it took to generate the response: Python 3.8+ import time from typing import Callable from fastapi import APIRouter , FastAPI , Request , Response from fastapi.routing import APIRoute class TimedRoute ( APIRoute ): def get_route_handler ( ...
https://man.mtool.work/fastapi/0.115/how-to/custom-request-and-route/
メタデータとドキュメントのURL 7873
メタデータとドキュメントのURL FastAPI アプリケーションのいくつかのメタデータの設定をカスタマイズできます。 タイトル、説明文、バージョン 以下を設定できます: タイトル : OpenAPIおよび自動APIドキュメントUIでAPIのタイトル/名前として使用される。 ... タグ毎にひとつの辞書を含むリストをとります。 それぞれの辞書は以下をもつことができます: name ( 必須 ): path operations および APIRouter の tags パラメーターで使用するのと同じタグ名である str 。 description : タグの簡単な説明文である str 。 Markdownで記述でき ... タグにメタデータを追加する必要はありません。 自作タグの使用 tags パラメーターを使用して、それぞれの path operations (および APIRouter ) を異なるタグに割り当てます: Python 3.8+ from fastapi import FastAPI tags_metadata = [ { "name" : "users" , "description" ...
https://man.mtool.work/fastapi/0.115/tutorial/metadata/
OpenAPI Webhooks 7783
OpenAPI Webhooks Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . There are cases where you want to tell your API users that your app could call their app (sending ... you define will end up in the OpenAPI schema and the automatic docs UI . Info The app.webhooks object is actually just an APIRouter , the same type you would use when structuring your app with multiple files. Notice that with webhooks you are actually no ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-webhooks/
静的ファイル 7783
静的ファイル StaticFiles を使用して、ディレクトリから静的ファイルを自動的に提供できます。 StaticFiles の使用 StaticFiles をインポート。 StaticFiles() インスタンスを生成し、特定のパスに「マウント」。 Python 3.8+ from fastapi import FastAPI f ... 味します。これにより、すべてのサブパスの処理がなされます。 これは、マウントされたアプリケーションが完全に独立しているため、 APIRouter とは異なります。メインアプリケーションのOpenAPIとドキュメントには、マウントされたアプリケーションの内容などは含まれません。 ...
https://man.mtool.work/fastapi/0.115/tutorial/static-files/
カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス 7585
カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス デフォルトでは、 FastAPI は JSONResponse を使ってレスポンスを返します。 レスポンスを直接返す で見たように、 Response を直接返すことでこの挙動をオーバーライドできます。 しか ... "/" ) async def main (): return FileResponse ( some_file_path ) デフォルトレスポンスクラス FastAPI クラスのインスタンスか APIRouter を生成するときに、デフォルトのレスポンスクラスを指定できます。 定義するためのパラメータは、 default_response_class です。 ...
https://man.mtool.work/fastapi/0.115/advanced/custom-response/
Release Notes 7495
Release Notes Latest Changes 0.115.11 Fixes ? Add docs examples and tests (support) for Annotated custom validations, like AfterValidator , revert #13440 . PR #13442 by @tiangolo . New docs: Query Parameters and String Validations - Custom ... /dependencies-with-yield.md . PR #11848 by @Joao-Pedro-P-Holanda . ? Add Portuguese translation for docs/pt/docs/reference/apirouter.md . PR #11843 by @lucasbalieiro . Internal ? Update sponsors: add liblab. PR #11934 by @tiangolo . ? Update GitHub Action ... docs/de/docs/reference/dependencies.md . PR #10818 by @nilslindemann . ? Add German translation for docs/de/docs/reference/apirouter.md . PR #10819 by @nilslindemann . ? Add German translation for docs/de/docs/reference/websockets.md . PR #10822 by @nilsl ...
https://man.mtool.work/fastapi/0.115/release-notes/
PREV 1 NEXT