コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 4 of about 4 for Hero (0.007 sec.)
SQL (Relational) Databases 12426
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 ... t Depends , FastAPI , HTTPException , Query from sqlmodel import Field , Session , SQLModel , create_engine , select class Hero ( SQLModel , table = True ): id : int | None = Field ( default = None , primary_key = True ) name : str = Field ( index = ... t Depends , FastAPI , HTTPException , Query from sqlmodel import Field , Session , SQLModel , create_engine , select class Hero ( SQLModel , table = True ): id : int | None = Field ( default = None , primary_key = True ) name : str = Field ( index = ... ( get_session )] app = FastAPI () @app . on_event ( "startup" ) def on_startup (): create_db_and_tables () @app . post ( "/heroes/" ) def create_hero ( hero : Hero , session : SessionDep ) -> Hero : session . add ( hero ) session . commit () session ...
https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
テスト 8395
テスト Starlette のおかげで、 FastAPI アプリケーションのテストは簡単で楽しいものになっています。 HTTPX がベースなので、非常に使いやすく直感的です。 これを使用すると、 FastAPI と共に pytest を直接利用できます。 TestClient を使用 TestClient を ... fake_secret_token = "coneofsilence" fake_db = { "foo" : { "id" : "foo" , "title" : "Foo" , "description" : "There goes my hero" }, "bar" : { "id" : "bar" , "title" : "Bar" , "description" : "The bartenders" }, } app = FastAPI () class Item ( BaseMod ... fake_secret_token = "coneofsilence" fake_db = { "foo" : { "id" : "foo" , "title" : "Foo" , "description" : "There goes my hero" }, "bar" : { "id" : "bar" , "title" : "Bar" , "description" : "The bartenders" }, } app = FastAPI () class Item ( BaseMod ... fake_secret_token = "coneofsilence" fake_db = { "foo" : { "id" : "foo" , "title" : "Foo" , "description" : "There goes my hero" }, "bar" : { "id" : "bar" , "title" : "Bar" , "description" : "The bartenders" }, } app = FastAPI () class Item ( BaseMod ...
https://man.mtool.work/fastapi/0.115/tutorial/testing/
Additional Responses in OpenAPI 8173
Additional Responses in OpenAPI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Warning This is a rather advanced topic. If you are starting with FastAPI , you mig ... Message }}) async def read_item ( item_id : str ): if item_id == "foo" : return { "id" : "foo" , "value" : "there goes my hero" } return JSONResponse ( status_code = 404 , content = { "message" : "Item not found" }) Note Keep in mind that you have t ... g : return FileResponse ( "image.png" , media_type = "image/png" ) else : return { "id" : "foo" , "value" : "there goes my hero" } Note Notice that you have to return the image using a FileResponse directly. Info Unless you specify a different media ... } }, }, }, ) async def read_item ( item_id : str ): if item_id == "foo" : return { "id" : "foo" , "value" : "there goes my hero" } else : return JSONResponse ( status_code = 404 , content = { "message" : "Item not found" }) It will all be combined an ...
https://man.mtool.work/fastapi/0.115/advanced/additional-responses/
モデル - より詳しく 7951
モデル - より詳しく 先ほどの例に続き、複数の関連モデルを持つことが一般的です。 これはユーザーモデルの場合は特にそうです。なぜなら: 入力モデル にはパスワードが必要です。 出力モデル はパスワードをもつべきではありません。 データベースモデル は ... API () class Item ( BaseModel ): name : str description : str items = [ { "name" : "Foo" , "description" : "There comes my hero" }, { "name" : "Red" , "description" : "It's my aeroplane" }, ] @app . get ( "/items/" , response_model = List [ Item ]) a ... API () class Item ( BaseModel ): name : str description : str items = [ { "name" : "Foo" , "description" : "There comes my hero" }, { "name" : "Red" , "description" : "It's my aeroplane" }, ] @app . get ( "/items/" , response_model = list [ Item ]) a ...
https://man.mtool.work/fastapi/0.115/tutorial/extra-models/
PREV 1 NEXT