Results of 1 - 6 of about 6 for context (0.010 sec.)
- OAuth2 scopes 11643
- OAuth2 scopes Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use OAuth2 scopes directly with FastAPI , they are integrated to work seamlessly. This would
...2PasswordBearer , OAuth2PasswordRequestForm , SecurityScopes , ) from jwt.exceptions import InvalidTokenError from passlib.context import CryptContext from pydantic import BaseModel , ValidationError # to get a string like this run: # openssl rand -hex...None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ,...ser." , "items" : "Read items." }, ) app = FastAPI () def verify_password ( plain_password , hashed_password ): return pwd_context . verify ( plain_password , hashed_password ) def get_password_hash ( password ): return pwd_context . hash ( password ) d... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 11479
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...同時にログインできるようになります。 パスワードのハッシュ化と検証 必要なツールを passlib からインポートします。 PassLib の「context」を作成します。これは、パスワードのハッシュ化と検証に使用されるものです。 豆知識 PassLibのcontextには、検証だけが許された非...security import OAuth2PasswordBearer , OAuth2PasswordRequestForm from jwt.exceptions import InvalidTokenError from passlib.context import CryptContext from pydantic import BaseModel # to get a string like this run: # openssl rand -hex 32 SECRET_KEY = "0...e : Union [ str , None ] = None disabled : Union [ bool , None ] = None class UserInDB ( User ): hashed_password : str pwd_context = CryptContext ( schemes = [ "bcrypt" ], deprecated = "auto" ) oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" )... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
- Lifespan Events 8902
- Lifespan Events Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can define logic (code) that should be executed before the application starts up . This means t
...ng loaded. Lifespan You can define this startup and shutdown logic using the lifespan parameter of the FastAPI app, and a "context manager" (I'll show you what that is in a second). Let's start with an example and then see it in detail. We create an asy...nc function lifespan() with yield like this: Python 3.8+ from contextlib import asynccontextmanager from fastapi import FastAPI def fake_answer_to_everything_ml_model ( x : float ): return x *...42 ml_models = {} @asynccontextmanager async def lifespan ( app : FastAPI ): # Load the ML model ml_models [ "answer_to_everything" ] = fake_answer_to_eve... - https://man.mtool.work/fastapi/0.115/advanced/events/
- Templates 8445
- Templates Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can use any template engine you want with FastAPI . A common choice is Jinja2, the same one used by F
...templates you created to render and return a TemplateResponse , pass the name of the template, the request object, and a "context" dictionary with key-value pairs to be used inside of the Jinja2 template. Python 3.8+ from fastapi import FastAPI , Reque...read_item ( request : Request , id : str ): return templates . TemplateResponse ( request = request , name = "item.html" , context = { "id" : id } ) Note Before FastAPI 0.108.0, Starlette 0.29.0, the name was the first parameter. Also, before that, in p...revious versions, the request object was passed as part of the key-value pairs in the context for Jinja2. Tip By declaring response_class=HTMLResponse the docs UI will be able to know that the response will be HTML.... - https://man.mtool.work/fastapi/0.115/advanced/templates/
- yieldを持つ依存関係 7202
- yieldを持つ依存関係 FastAPIは、いくつかの 終了後の追加のステップ を行う依存関係をサポートしています。 これを行うには、 return の代わりに yield を使い、その後に追加のステップを書きます。 豆知識 yield は必ず一度だけ使用するようにしてください。
...により async-exit-stack と async-generator がインストールされます。 技術詳細 以下と一緒に使用できる関数なら何でも有効です: @contextlib.contextmanager または @contextlib.asynccontextmanager これらは FastAPI の依存関係として使用するのに有効です。 実際、Fas...す。 依存関係の組み合わせは自由です。 FastAPI は、全てが正しい順序で実行されていることを確認します。 技術詳細 これはPythonの Context Managers のおかげで動作します。 FastAPI はこれを実現するために内部的に使用しています。 yield と HTTPException を持つ依存関...ith 文を使用することによって yield を持つ FastAPI の依存関係の中でそれらを使用することができます: Python 3.8+ class MySuperContextManager : def __init__ ( self ): self . db = DBSession () def __enter__ ( self ): return self . db def __exit__ ( self , ex... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/dependencies-with-yie...
- Release Notes 7128
- 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
...s. PR #12029 by @tiangolo . ? Add .coverage* to .gitignore . PR #11940 by @gitworkflows . ⚙️ Record and show test coverage contexts (what test covers which line). PR #11518 by @slafs . 0.112.1 Upgrades ⬆️ Allow Starlette 0.38.x, update the pin to >=0.37...1337 . ? Remove Vietnamese note about missing translation. PR #9957 by @tiangolo . Internal ? Add GitHub Actions step dump context to debug external failures. PR #10008 by @tiangolo . ? Restore MkDocs Material pin after the fix. PR #10001 by @tiangolo .... - https://man.mtool.work/fastapi/0.115/release-notes/
PREV
1
NEXT