コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 76 for path (0.003 sec.)
Behind a Proxy 12897
Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration ... that adds an extra path prefix that is not seen by your application. In these cases you can use root_path to configure your application. The root_ ... path is a mechanism provided by the ASGI specification (that FastAPI is built on, through Starlette). The root_path is used to handle these specific cases. And it's also used internally when mounting sub-applications. Proxy with a strippe ... d path prefix Having a proxy with a stripped path prefix, in this case, means that you could declare a path at /app in your code, ...
https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
パスパラメータと数値の検証 11567
パスパラメータと数値の検証 クエリパラメータに対して Query でより多くのバリデーションとメタデータを宣言できるのと同じように、パスパラメータに対しても Path で同じ種類のバリデーションとメタデータを宣言することができます。 Pathのインポート まず ... 初めに、 fastapi から Path をインポートします: Python 3.8+ - non-Annotated from typing import Union from fastapi import FastAPI , Path , Query app = ... FastAPI () @app . get ( "/items/ {item_id} " ) async def read_items ( item_id : int = Path ( title = "The ID of the item to get" ), q : Union [ str , None ] = Query ( default = None , alias = "item-query" ), ): re ... thon 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated from typing import Annotated from fastapi import FastAPI , Path , Query app = FastAPI () @app . get ( "/items/ {item_id} " ) async def read_items ( item_id : Annotated [ int , Path ( tit ...
https://man.mtool.work/fastapi/0.115/tutorial/path-params-numeric-validations/
Sub Applications - Mounts 10625
Sub Applications - Mounts Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you need to have two independent FastAPI applications, with their own independent Open ... pplication(s). Mounting a FastAPI application "Mounting" means adding a completely "independent" application in a specific path, that then takes care of handling everything under that path, with the path operations declared in that sub-application. T ... op-level application First, create the main, top-level, FastAPI application, and its path operations : Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/app" ) def read_main (): return { "me ... "Hello World from sub API" } app . mount ( "/subapi" , subapi ) Sub-application Then, create your sub-application, and its path operations . This sub-application is just another standard FastAPI application, but this is the one that will be "mounted" ...
https://man.mtool.work/fastapi/0.115/advanced/sub-applications/
Bigger Applications - Multiple Files 9766
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 ... outer Let's say the file dedicated to handling just users is the submodule at /app/routers/users.py . You want to have the path operations related to your users separated from the rest of the code, to keep it organized. But it's still part of the sam ... e FastAPI 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 woul ... get ( "/users/ {username} " , tags = [ "users" ]) async def read_user ( username : str ): return { "username" : username } Path operations with APIRouter And then you use it to declare your path operations . Use it the same way you would use the Fast ...
https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
OpenAPI Callbacks 9489
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 ... ably created by the same developer). In this case, you could want to document how that external API should look like. What path operation it should have, what body it should expect, what response it should return, etc. An app with callbacks Let's see ... . The normal FastAPI app Let's first see how the normal API app would look like before adding the callback. It will have a path operation that will receive an Invoice body, and a query parameter callback_url that will contain the URL for the callback ... ): """ Create an invoice. This will (let's imagine) let the API user (some external developer) create an invoice. And this path operation will: * Send the invoice to the client. * Collect the money from the client. * Send a notification back to the A ...
https://man.mtool.work/fastapi/0.115/advanced/openapi-callbacks/
General - How To - Recipes 9364
General - How To - Recipes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Here are several pointers to other places in the docs, for general or frequent questions ... n you should, read the docs for Tutorial - Response Model - Return Type . Documentation Tags - OpenAPI To add tags to your path operations , and group them in the docs UI, read the docs for Tutorial - Path Operation Configurations - Tags . Documentat ... ion Summary and Description - OpenAPI To add a summary and description to your path operations , and show them in the docs UI, read the docs for Tutorial - Path Operation Configurations - Summary and Descri ... sponse description - OpenAPI To define the description of the response, shown in the docs UI, read the docs for Tutorial - Path Operation Configurations - Response description . Documentation Deprecate a Path Operation - OpenAPI To deprecate a path o ...
https://man.mtool.work/fastapi/0.115/how-to/general/
Generate Clients 8672
Generate Clients Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . As FastAPI is based on the OpenAPI specification, you get automatic compatibility with many tools, ... get_items (): return [ { "name" : "Plumbus" , "price" : 3 }, { "name" : "Portal Gun" , "price" : 9001 }, ] Notice that the path operations define the models they use for request payload and response payload, using the models Item and ResponseMessage ... pp with Tags In many cases your FastAPI app will be bigger, and you will probably use tags to separate different groups of path operations . For example, you could have a section for items and another section for users , and they could be separated b ... ({ name : "Plumbus" , price : 5 }) ...that's because the client generator uses the OpenAPI internal operation ID for each path operation . OpenAPI requires that each operation ID is unique across all the path operations , so FastAPI uses the functio ...
https://man.mtool.work/fastapi/0.115/advanced/generate-clients/
パスパラメータ 8353
パスパラメータ Pythonのformat文字列と同様のシンタックスで「パスパラメータ」や「パス変数」を宣言できます: Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/items/ {item_id} " ) async def read_item ( item_id ): return { ... ション しかしブラウザで http://127.0.0.1:8000/items/foo を開くと、次のHTTPエラーが表示されます: { "detail" : [ { "loc" : [ "path" , "item_id" ], "msg" : "value is not a valid integer" , "type" : "type_error.integer" } ] } これは、パスパラメータ item_i ... 他の多くの複雑なデータ型を型宣言に使用できます。 これらのいくつかについては、チュートリアルの次の章で説明します。 順序の問題 path operations を作成する際、固定パスをもつ状況があり得ます。 /users/me から、現在のユーザに関するデータを取得するとします。 さ ... らに、ユーザIDによって特定のユーザに関する情報を取得するパス /users/{user_id} ももつことができます。 path operations は順に評価されるので、 /users/me が /users/{user_id} よりも先に宣言されているか確認する必要があります: Python 3 ...
https://man.mtool.work/fastapi/0.115/tutorial/path-params/
依存関係 - 最初のステップ 8311
依存関係 - 最初のステップ ** FastAPI** は非常に強力でありながら直感的な 依存性注入 システムを持っています。 それは非常にシンプルに使用できるように設計されており、開発者が他のコンポーネント FastAPI と統合するのが非常に簡単になるように設計され ... ています。 「依存性注入」とは 「依存性注入」 とは、プログラミングにおいて、コード(この場合は、 path operation関数 )が動作したり使用したりするために必要なもの(「依存関係」)を宣言する方法があることを意味します: そして、そ ... テムがどのように機能するかに焦点を当てることができます。 依存関係の作成 まずは依存関係に注目してみましょう。 以下のように、 path operation関数 と同じパラメータを全て取ることができる関数にすぎません: Python 3.8+ - non-Annotated from typing import Union ... read_users ( commons : dict = Depends ( common_parameters )): return commons これだけです。 2行 。 そして、それはすべての path operation関数 が持っているのと同じ形と構造を持っています。 「デコレータ」を含まない( @app.get("/some-path") を含まない) ...
https://man.mtool.work/fastapi/0.115/tutorial/dependencies/
カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス 8270
カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス デフォルトでは、 FastAPI は JSONResponse を使ってレスポンスを返します。 レスポンスを直接返す で見たように、 Response を直接返すことでこの挙動をオーバーライドできます。 しか ... れません (例えば、生成されるOpenAPIの一部としてHTTPヘッダー Content-Type に特定の「メディアタイプ」を含めるなど) 。 しかし、 path operationデコレータ に、使いたい Response を宣言することもできます。 path operation関数 から返されるコンテンツは、その Res ... てもし、 Response が、 JSONResponse や UJSONResponse の場合のようにJSONメディアタイプ ( application/json ) ならば、データは path operationデコレータ に宣言したPydantic response_model により自動的に変換 (もしくはフィルタ) されます。 備考 メディアタイプ ... ールし、 ORJSONResponse をレスポンスとしてセットすることができます。 使いたい Response クラス (サブクラス) をインポートし、 path operationデコレータ に宣言します。 Python 3.8+ from fastapi import FastAPI from fastapi.responses import ORJSONResponse ap ...
https://man.mtool.work/fastapi/0.115/advanced/custom-response/
PREV 1 2 3 4 5 6 7 8 NEXT