Results of 1 - 8 of about 8 for session (0.009 sec.)
- SQL (Relational) Databases 13628
- 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
...0+ from typing import Annotated from fastapi import Depends , FastAPI , HTTPException , Query from sqlmodel import Field , Session , SQLModel , create_engine , select class Hero ( SQLModel , table = True ): id : int | None = Field ( default = None , pri...0+ from typing import Annotated from fastapi import Depends , FastAPI , HTTPException , Query from sqlmodel import Field , Session , SQLModel , create_engine , select class Hero ( SQLModel , table = True ): id : int | None = Field ( default = None , pri...qlite_url , connect_args = connect_args ) def create_db_and_tables (): SQLModel . metadata . create_all ( engine ) def get_session (): with Session ( engine ) as session : yield session SessionDep = Annotated [ Session , Depends ( get_session )] app = F... - https://man.mtool.work/fastapi/0.115/tutorial/sql-databases/
- WebSocket 9254
- WebSocket FastAPI で WebSocket が使用できます。 WebSockets のインストール まず WebSockets のインストールが必要です。 $ pip install websockets ---> 100% WebSocket クライアント 本番環境 本番環境では、React、Vue.js、Angularなどの最新のフレーム
...@app . get ( "/" ) async def get (): return HTMLResponse ( html ) async def get_cookie_or_token ( websocket : WebSocket , session : Union [ str , None ] = Cookie ( default = None ), token : Union [ str , None ] = Query ( default = None ), ): if session...is None and token is None : raise WebSocketException ( code = status . WS_1008_POLICY_VIOLATION ) return session or token @app . websocket ( "/items/ {item_id} /ws" ) async def websocket_endpoint ( websocket : WebSocket , item_id : str...n ), ): await websocket . accept () while True : data = await websocket . receive_text () await websocket . send_text ( f "Session cookie or query token value is: { cookie_or_token } " ) if q is not None : await websocket . send_text ( f "Query paramete... - https://man.mtool.work/fastapi/0.115/advanced/websockets/
- クッキーパラメータモデル 9145
- クッキーパラメータモデル もし関連する 複数のクッキー から成るグループがあるなら、それらを宣言するために、 Pydanticモデル を作成できます。? こうすることで、 複数の場所 で そのPydanticモデルを再利用 でき、バリデーションやメタデータを、すべての
...nnotated from fastapi import Cookie , FastAPI from pydantic import BaseModel app = FastAPI () class Cookies ( BaseModel ): session_id : str fatebook_tracker : str | None = None googall_tracker : str | None = None @app . get ( "/items/" ) async def read_..., Union from fastapi import Cookie , FastAPI from pydantic import BaseModel app = FastAPI () class Cookies ( BaseModel ): session_id : str fatebook_tracker : Union [ str , None ] = None googall_tracker : Union [ str , None ] = None @app . get ( "/items...stAPI from pydantic import BaseModel from typing_extensions import Annotated app = FastAPI () class Cookies ( BaseModel ): session_id : str fatebook_tracker : Union [ str , None ] = None googall_tracker : Union [ str , None ] = None @app . get ( "/items... - https://man.mtool.work/fastapi/0.115/tutorial/cookie-param-models/
- Response Cookies 8278
- Response Cookies Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Use a Response parameter You can declare a parameter of type Response in your path operation funct
...API () @app . post ( "/cookie-and-object/" ) def create_cookie ( response : Response ): response . set_cookie ( key = "fakesession" , value = "fake-cookie-session-value" ) return { "message" : "Come to the dark side, we have cookies" } And then you can...Come to the dark side, we have cookies" } response = JSONResponse ( content = content ) response . set_cookie ( key = "fakesession" , value = "fake-cookie-session-value" ) return response Tip Keep in mind that if you return a response directly instead o... - https://man.mtool.work/fastapi/0.115/advanced/response-cookies/
- Release Notes 8043
- 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
...nnotated from fastapi import Cookie , FastAPI from pydantic import BaseModel app = FastAPI () class Cookies ( BaseModel ): session_id : str fatebook_tracker : str | None = None googall_tracker : str | None = None @app . get ( "/items/" ) async def read_...nly data that doesn't depend on the resources of dependencies with yield . For example, instead of using the same database session, you would create a new database session inside of the background task, and you would obtain the objects from the database...using this new session. And then instead of passing the object from the database as a parameter to the background task function, you would pass t... - https://man.mtool.work/fastapi/0.115/release-notes/
- yieldを持つ依存関係 8007
- yieldを持つ依存関係 FastAPIは、いくつかの 終了後の追加のステップ を行う依存関係をサポートしています。 これを行うには、 return の代わりに yield を使い、その後に追加のステップを書きます。 豆知識 yield は必ず一度だけ使用するようにしてください。
...とができます。 レスポンスを送信する前に yield 文を含む前のコードのみが実行されます。 Python 3.8+ async def get_db (): db = DBSession () try : yield db finally : db . close () 生成された値は、 path operations や他の依存関係に注入されるものです: Python 3.8+...async def get_db (): db = DBSession () try : yield db finally : db . close () yield 文に続くコードは、レスポンスが送信された後に実行されます: Python 3.8+ asyn...c def get_db (): db = DBSession () try : yield db finally : db . close () 豆知識 async や通常の関数を使用することができます。 FastAPI は、通常の依存関係と... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/dependencies-with-yie...
- Virtual Environments 7952
- Virtual Environments Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . When you work in Python projects you probably should use a virtual environment (or a similar m
...ronment so that any Python command you run or package you install uses it. Tip Do this every time you start a new terminal session to work on the project. Linux, macOS Windows PowerShell Windows Bash $ source .venv/bin/activate $ .venv \S cripts \A ctiv... - https://man.mtool.work/fastapi/0.115/virtual-environments/
- テスト 7916
- テスト Starlette のおかげで、 FastAPI アプリケーションのテストは簡単で楽しいものになっています。 HTTPX がベースなので、非常に使いやすく直感的です。 これを使用すると、 FastAPI と共に pytest を直接利用できます。 TestClient を使用 TestClient を
...ファイルを検知し、自動テストを実行し、結果のレポートを返します。 以下でテストを実行します: $ pytest ================ test session starts ================ platform linux -- Python 3.6.9, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 rootdir: /home/user/code/sup... - https://man.mtool.work/fastapi/0.115/tutorial/testing/
PREV
1
NEXT