Results of 1 - 10 of about 136 for FastAPI (0.011 sec.)
- External Links and Articles 8588
- External Links and Articles FastAPI has a great community constantly growing. There are many posts, articles, tools, and projects, related to FastAPI . Here's an incomplete list of some of them. Tip If you have an article, project, tool, or
...anything related to FastAPI that is not yet listed here, create a Pull Request adding it . Articles English How to profile a FastAPI asynchronous requ...est by Balthazar Rouberol . Deploy a Serverless FastAPI App with Neon Postgres and AWS App Runner at any scale by Stephen Siegert - Neon . Building a Machine Learning Microservic...e with FastAPI by Kurtis Pykes - NVIDIA . Booking Appointments with Twilio, Notion, and FastAPI by Ravgeet Dhillon - Twilio . Write a Pyt... - https://man.mtool.work/fastapi/0.115/external-links/
- クエリパラメータと文字列の検証 8383
- クエリパラメータと文字列の検証 FastAPI ではパラメータの追加情報とバリデーションを宣言することができます。 以下のアプリケーションを例にしてみましょう: Python 3.8+ from typing import Union from fastapi import FastAPI app = FastAPI () @app . g
..."item_id" : "Bar" }]} if q : results . update ({ "q" : q }) return results ? Other versions and variants Python 3.10+ from fastapi import FastAPI app = FastAPI () @app . get ( "/items/" ) async def read_items ( q : str | None = None ): results = { "item...results クエリパラメータ q は Optional[str] 型で、 None を許容する str 型を意味しており、デフォルトは None です。そのため、FastAPIはそれが必須ではないと理解します。 備考 FastAPIは、 q はデフォルト値が =None であるため、必須ではないと理解します。 Optional...[str] における Optional はFastAPIには利用されませんが、エディターによるより良いサポートとエラー検出を可能にします。 バリデーションの追加 q はオプショナルです... - https://man.mtool.work/fastapi/0.115/tutorial/query-params-str-validations/
- 現在のユーザーの取得 8011
- 現在のユーザーの取得 一つ前の章では、(依存性注入システムに基づいた)セキュリティシステムは、 path operation関数 に str として token を与えていました: Python 3.8+ - non-Annotated from fastapi import Depends , FastAPI from fastapi.security i
...mport OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) @app . get ( "/items/" ) async def read_items ( token : str...eme )): return { "token" : token } ? Other versions and variants Python 3.9+ Python 3.8+ from typing import Annotated from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer app = FastAPI () oauth2_scheme = OAuth2Password..."/items/" ) async def read_items ( token : Annotated [ str , Depends ( oauth2_scheme )]): return { "token" : token } from fastapi import Depends , FastAPI from fastapi.security import OAuth2PasswordBearer from typing_extensions import Annotated app = F... - https://man.mtool.work/fastapi/0.115/tutorial/security/get-current-user/
- 依存関係としてのクラス 7939
- 依存関係としてのクラス 依存性注入 システムを深く掘り下げる前に、先ほどの例をアップグレードしてみましょう。 前の例の dict 前の例では、依存関係("dependable")から dict を返していました: Python 3.8+ - non-Annotated from typing import Union fr
...om fastapi import Depends , FastAPI app = FastAPI () async def common_parameters ( q : Union [ str , None ] = None , skip : int = 0 ,...versions and variants Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated from typing import Annotated from fastapi import Depends , FastAPI app = FastAPI () async def common_parameters ( q : str | None = None , skip : int = 0 , limit : i...s ( commons : Annotated [ dict , Depends ( common_parameters )]): return commons from typing import Annotated , Union from fastapi import Depends , FastAPI app = FastAPI () async def common_parameters ( q : Union [ str , None ] = None , skip : int = 0 ,... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/classes-as-dependenci...
- Request Files 7915
- Request Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can define files to be uploaded by the client using File . Info To receive uploaded files, first
...stall python-multipart This is because uploaded files are sent as "form data". Import File Import File and UploadFile from fastapi : Python 3.9+ from typing import Annotated from fastapi import FastAPI , File , UploadFile app = FastAPI () @app . post (...File ): return { "filename" : file . filename } ? Other versions and variants Python 3.8+ Python 3.8+ - non-Annotated from fastapi import FastAPI , File , UploadFile from typing_extensions import Annotated app = FastAPI () @app . post ( "/files/" ) asyn...e ( file : UploadFile ): return { "filename" : file . filename } Tip Prefer to use the Annotated version if possible. from fastapi import FastAPI , File , UploadFile app = FastAPI () @app . post ( "/files/" ) async def create_file ( file : bytes = File... - https://man.mtool.work/fastapi/0.115/tutorial/request-files/
- ヘッダーのパラメータ 7807
- ヘッダーのパラメータ ヘッダーのパラメータは、 Query や Path 、 Cookie のパラメータを定義するのと同じように定義できます。 Header をインポート まず、 Header をインポートします: Python 3.8+ - non-Annotated from typing import Union from fastapi
...import FastAPI , Header app = FastAPI () @app . get ( "/items/" ) async def read_items ( user_agent : Union [ str , None ] = Header ( def...versions and variants Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated from typing import Annotated from fastapi import FastAPI , Header app = FastAPI () @app . get ( "/items/" ) async def read_items ( user_agent : Annotated [ str | No...ne , Header ()] = None ): return { "User-Agent" : user_agent } from typing import Annotated , Union from fastapi import FastAPI , Header app = FastAPI () @app . get ( "/items/" ) async def read_items ( user_agent : Annotated [ Union [... - https://man.mtool.work/fastapi/0.115/tutorial/header-params/
- ボディ - ネストされたモデル 7735
- ボディ - ネストされたモデル FastAPI を使用すると、深くネストされた任意のモデルを定義、検証、文書化、使用することができます(Pydanticのおかげです)。 リストのフィールド 属性をサブタイプとして定義することができます。例えば、Pythonの list は以
...下のように定義できます: Python 3.8+ from typing import Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [...: Item ): results = { "item_id" : item_id , "item" : item } return results ? Other versions and variants Python 3.10+ from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : str | No...ポート まず、Pythonの標準の typing モジュールから List をインポートします: Python 3.8+ from typing import List , Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : Union [... - https://man.mtool.work/fastapi/0.115/tutorial/body-nested-models/
- パスパラメータと数値の検証 7639
- パスパラメータと数値の検証 クエリパラメータに対して Query でより多くのバリデーションとメタデータを宣言できるのと同じように、パスパラメータに対しても Path で同じ種類のバリデーションとメタデータを宣言することができます。 Pathのインポート まず
...初めに、 fastapi から Path をインポートします: Python 3.8+ - non-Annotated from typing import Union from fastapi import FastAPI , Path , Qu...ery app = FastAPI () @app . get ( "/items/ {item_id} " ) async def read_items ( item_id : int = Path ( title = "The ID of the item to get" )...versions and variants Python 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 : Annota... - https://man.mtool.work/fastapi/0.115/tutorial/path-params-numeric-validations/
- SQL (Relational) Databases 7555
- SQL (Relational) Databases Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI doesn't require you to use a SQL (relational) database. But you can use any data
...'ll see an example using SQLModel . SQLModel is built on top of SQLAlchemy and Pydantic. It was made by the same author of FastAPI to be the perfect match for FastAPI applications that need to use SQL databases . Tip You could use any other SQL or NoSQL...database library you want (in some cases called "ORMs" ), FastAPI doesn't force you to use anything. ? As SQLModel is based on SQLAlchemy, you can easily use any database supported by SQLA...ion application, you might want to use a database server like PostgreSQL . Tip There is an official project generator with FastAPI and PostgreSQL including a frontend and more tools: https://github.com/fastapi/full-stack-fastapi-template This is a very... - https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
- ボディ - 複数のパラメータ 7507
- ボディ - 複数のパラメータ これまで Path と Query をどう使うかを見てきましたが、リクエストボディの宣言のより高度な使い方を見てみましょう。 Path 、 Query とボディパラメータを混ぜる まず、もちろん、 Path と Query とリクエストボディのパラメータ
...の宣言は自由に混ぜることができ、 FastAPI は何をするべきかを知っています。 また、デフォルトの None を設定することで、ボディパラメータをオプションとして宣言することも...できます: Python 3.8+ - non-Annotated from typing import Union from fastapi import FastAPI , Path from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : U...versions and variants Python 3.10+ Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotated from typing import Annotated from fastapi import FastAPI , Path from pydantic import BaseModel app = FastAPI () class Item ( BaseModel ): name : str description : s... - https://man.mtool.work/fastapi/0.115/tutorial/body-multiple-params/