コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 10 of about 10 for config (0.005 sec.)
Settings and Environment Variables 14069
Settings and Environment Variables Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In many cases your application could need some external settings or configuratio ... . admin_email , "items_per_user" : settings . items_per_user , } Run the server Next, you would run the server passing the configurations as environment variables, for example you could set an ADMIN_EMAIL and APP_NAME with: $ ADMIN_EMAIL = "deadpool@ex ... se settings in another module file as you saw in Bigger Applications - Multiple Files . For example, you could have a file config.py with: Python 3.8+ from pydantic_settings import BaseSettings class Settings ( BaseSettings ): app_name : str = "Awesome ... r_user : int = 50 settings = Settings () And then use it in a file main.py : Python 3.8+ from fastapi import FastAPI from .config import settings app = FastAPI () @app . get ( "/info" ) async def info (): return { "app_name" : settings . app_name , "ad ...
https://man.mtool.work/fastapi/0.115/advanced/settings/
Header Parameter Models 9206
Header Parameter Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you have a group of related header parameters , you can create a Pydantic model to decla ... (probably not very common), you might want to restrict the headers that you want to receive. You can use Pydantic's model configuration to forbid any extra fields: Python 3.10+ from typing import Annotated from fastapi import FastAPI , Header from pyd ... antic import BaseModel app = FastAPI () class CommonHeaders ( BaseModel ): model_config = { "extra" : "forbid" } host : str save_data : bool if_modified_since : str | None = None traceparent : str | None = None ... m fastapi import FastAPI , Header from pydantic import BaseModel app = FastAPI () class CommonHeaders ( BaseModel ): model_config = { "extra" : "forbid" } host : str save_data : bool if_modified_since : Union [ str , None ] = None traceparent : Union [ ...
https://man.mtool.work/fastapi/0.115/tutorial/header-param-models/
クエリパラメータモデル 8885
クエリパラメータモデル もし関連する 複数のクエリパラメータ から成るグループがあるなら、それらを宣言するために、 Pydanticモデル を作成できます。 こうすることで、 複数の場所 で そのPydanticモデルを再利用 でき、バリデーションやメタデータを、す ... り一般的ではないかもしれない)ケースで、受け付けるクエリパラメータを 制限 する必要があるかもしれません。 Pydanticのモデルの Configuration を利用して、 extra フィールドを forbid とすることができます。 Python 3.10+ from typing import Annotated , Literal f ... api import FastAPI , Query from pydantic import BaseModel , Field app = FastAPI () class FilterParams ( BaseModel ): model_config = { "extra" : "forbid" } limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = Field ( 0 , ge = 0 ) order_by : Li ... seModel , Field from typing_extensions import Annotated , Literal app = FastAPI () class FilterParams ( BaseModel ): model_config = { "extra" : "forbid" } limit : int = Field ( 100 , gt = 0 , le = 100 ) offset : int = Field ( 0 , ge = 0 ) order_by : Li ...
https://man.mtool.work/fastapi/0.115/tutorial/query-param-models/
クッキーパラメータモデル 8777
クッキーパラメータモデル もし関連する 複数のクッキー から成るグループがあるなら、それらを宣言するために、 Pydanticモデル を作成できます。? こうすることで、 複数の場所 で そのPydanticモデルを再利用 でき、バリデーションやメタデータを、すべての ... 制限 する必要があるかもしれません。 あなたのAPIは独自の クッキー同意 を管理する能力を持っています。 ?? Pydanticのモデルの Configuration を利用して、 extra フィールドを forbid とすることができます。 Python 3.9+ from typing import Annotated , Union from ... fastapi import Cookie , FastAPI from pydantic import BaseModel app = FastAPI () class Cookies ( BaseModel ): model_config = { "extra" : "forbid" } session_id : str fatebook_tracker : Union [ str , None ] = None googall_tracker : Union [ str , N ... ed from fastapi import Cookie , FastAPI from pydantic import BaseModel app = FastAPI () class Cookies ( BaseModel ): model_config = { "extra" : "forbid" } session_id : str fatebook_tracker : str | None = None googall_tracker : str | None = None @app . ...
https://man.mtool.work/fastapi/0.115/tutorial/cookie-param-models/
Form Models 8616
Form Models Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use Pydantic models to declare form fields in FastAPI. Info To use forms, first install python- ... model. And forbid any extra fields. Note This is supported since FastAPI version 0.114.0 . ? You can use Pydantic's model configuration to forbid any extra fields: Python 3.9+ from typing import Annotated from fastapi import FastAPI , Form from pydant ... ic import BaseModel app = FastAPI () class FormData ( BaseModel ): username : str password : str model_config = { "extra" : "forbid" } @app . post ( "/login/" ) async def login ( data : Annotated [ FormData , Form ()]): return data ... from typing_extensions import Annotated app = FastAPI () class FormData ( BaseModel ): username : str password : str model_config = { "extra" : "forbid" } @app . post ( "/login/" ) async def login ( data : Annotated [ FormData , Form ()]): return data ...
https://man.mtool.work/fastapi/0.115/tutorial/request-form-models/
Release Notes 8313
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 ... #13184 by @alejsdev . ✅ Simplify tests for path_query_params. PR #13181 by @alejsdev . ✅ Simplify tests for path_operation_configurations. PR #13180 by @alejsdev . ✅ Simplify tests for header_params. PR #13179 by @alejsdev . ✅ Simplify tests for extra_ ... slation for docs/ko/docs/resources/index.md . PR #13004 by @hard-coders . ? Add Korean translation for docs/ko/docs/how-to/configure-swagger-ui.md . PR #12898 by @nahyunkeem . ? Add Korean translation to docs/ko/docs/advanced/additional-status-codes.md ... nced/additional-responses.md . PR #12634 by @fegmorte . ? Update includes in docs/fr/docs/advanced/path-operation-advanced-configuration.md . PR #12633 by @kantandane . ? Update includes in docs/fr/docs/advanced/response-directly.md . PR #12632 by @kan ...
https://man.mtool.work/fastapi/0.115/release-notes/
Advanced Middleware 8205
Advanced Middleware Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In the main tutorial you read how to add Custom Middleware to your application. And then you al ... to do something like: from unicorn import UnicornMiddleware app = SomeASGIApp () new_app = UnicornMiddleware ( app , some_config = "rainbow" ) But FastAPI (actually Starlette) provides a simpler way to do it that makes sure that the internal middlewar ... tapi import FastAPI from unicorn import UnicornMiddleware app = FastAPI () app . add_middleware ( UnicornMiddleware , some_config = "rainbow" ) app.add_middleware() receives a middleware class as the first argument and any additional arguments to be pa ...
https://man.mtool.work/fastapi/0.115/advanced/middleware/
スキーマの追加 - 例 8152
スキーマの追加 - 例 JSON Schemaに追加する情報を定義することができます。 一般的なユースケースはこのドキュメントで示されているように example を追加することです。 JSON Schemaの追加情報を宣言する方法はいくつかあります。 Pydanticの schema_extra ... Pydanticのドキュメント: スキーマのカスタマイズ で説明されているように、 Config と schema_extra を使ってPydanticモデルの例を宣言することができます: Python 3.8+ from typing import Union from fastapi impo ... BaseModel ): name : str description : Union [ str , None ] = None price : float tax : Union [ float , None ] = None model_config = { "json_schema_extra" : { "examples" : [ { "name" : "Foo" , "description" : "A very nice Item" , "price" : 35.4 , "tax" ... tAPI () class Item ( BaseModel ): name : str description : str | None = None price : float tax : float | None = None model_config = { "json_schema_extra" : { "examples" : [ { "name" : "Foo" , "description" : "A very nice Item" , "price" : 35.4 , "tax" ...
https://man.mtool.work/fastapi/0.115/tutorial/schema-extra-example/
Development - Contributing 7562
Development - Contributing Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . First, you might want to see the basic ways to help FastAPI and get help . Developing If ... ck in your code editor the newly created directory docs/ht/ . That command created a file docs/ht/mkdocs.yml with a simple config that inherits everything from the en version: INHERIT : ../en/mkdocs.yml Tip You could also simply create that file with t ...
https://man.mtool.work/fastapi/0.115/contributing/
環境変数 7508
環境変数 Tip もし、「環境変数」とは何か、それをどう使うかを既に知っている場合は、このセクションをスキップして構いません。 環境変数( env var とも呼ばれる)はPythonコードの 外側 、つまり OS に存在する変数で、Pythonから読み取ることができます。 ... on // The env var no longer exists afterwards $ python main.py Hello World from Python Tip 詳しくは The Twelve-Factor App: Config を参照してください。 型とバリデーション 環境変数は テキスト文字列 のみを扱うことができます。これは、環境変数がPython外部に ...
https://man.mtool.work/fastapi/0.115/environment-variables/
PREV 1 NEXT