Results of 1 - 10 of about 12 for email (0.009 sec.)
- Settings and Environment Variables 11072
- 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
...ns, for example secret keys, database credentials, credentials for email services, etc. Most of these settings are variable (can change), like database URLs. And many could be sensitive, like sec...t FastAPI from pydantic_settings import BaseSettings class Settings ( BaseSettings ): app_name : str = "Awesome API" admin_email : str items_per_user : int = 50 settings = Settings () app = FastAPI () @app . get ( "/info" ) async def info (): return {..."app_name" : settings . app_name , "admin_email" : settings . admin_email , "items_per_user" : settings . items_per_user , } Info In Pydantic v1 you would import BaseSett... - https://man.mtool.work/fastapi/0.115/advanced/settings/
- バックグラウンドタスク 10948
- バックグラウンドタスク レスポンスを返した 後に 実行されるバックグラウンドタスクを定義できます。 これは、リクエスト後に処理を開始する必要があるが、クライアントがレスポンスを受け取る前に処理を終える必要のない操作に役立ちます。 これには、たとえ
...ラメーターを定義します: Python 3.8+ from fastapi import BackgroundTasks , FastAPI app = FastAPI () def write_notification ( email : str , message = "" ): with open ( "log.txt" , mode = "w" ) as email_file : content = f "notification for { email } : { m...essage } " email_file . write ( content ) @app . post ( "/send-notification/ {email} " ) async def send_notification ( email : str , backgr...ound_tasks : BackgroundTasks ): background_tasks . add_task ( write_notification , email , message = "some notification" ) return { "message" : "Notification sent in the background" } FastAPI は、 BackgroundTask... - https://man.mtool.work/fastapi/0.115/tutorial/background-tasks/
- 現在のユーザーの取得 10807
- 現在のユーザーの取得 一つ前の章では、(依存性注入システムに基づいた)セキュリティシステムは、 path operation関数 に str として token を与えていました: Python 3.8+ - non-Annotated from fastapi import Depends , FastAPI from fastapi.security i
...odel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : Union [ str , None ] = None full_name : Union [ str , None ] = None disabled : Union [ bool , None ] = None def fake_dec...ode_token ( token ): return User ( username = token + "fakedecoded" , email = "john@example.com" , full_name = "John Doe" ) async def get_current_user ( token : str = Depends ( oauth2_scheme )): use...odel app = FastAPI () oauth2_scheme = OAuth2PasswordBearer ( tokenUrl = "token" ) class User ( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None def fake_decode_token ( token ): return Us... - https://man.mtool.work/fastapi/0.115/tutorial/security/get-current-user/
- Simple OAuth2 with Password and Bearer 10789
- Simple OAuth2 with Password and Bearer Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Now let's build from the previous chapter and add the missing parts to have
...a username and password fields as form data. And the spec says that the fields have to be named like that. So user-name or email wouldn't work. But don't worry, you can show it as you wish to your final users in the frontend. And your database models...stForm from pydantic import BaseModel fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "fakehashedsecret" , "disabled" : False , }, "alice" : { "username" : "alic...e" , "full_name" : "Alice Wonderson" , "email" : "alice@example.com" , "hashed_password" : "fakehashedsecret2" , "disabled" : True , }, } app = FastAPI () def fake_hash... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- OAuth2 scopes 10170
- 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
...256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled"...: False , }, "alice" : { "username" : "alice" , "full_name" : "Alice Chains" , "email" : "alicechains@example.com" , "hashed_password" : "$2b$12$gSvqqUPvlXP2tfVFaWK1Be7DlH.PKZbv5H8KnzzVgXXbVxpva.pFm" , "disab...TokenData ( BaseModel ): username : str | None = None scopes : list [ str ] = [] class User ( BaseModel ): username : str email : str | None = None full_name : str | None = None disabled : bool | None = None class UserInDB ( User ): hashed_password :... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 8649
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled"..._type : str class TokenData ( BaseModel ): username : Union [ str , None ] = None class User ( BaseModel ): username : str email : Union [ str , None ] = None full_name : Union [ str , None ] = None disabled : Union [ bool , None ] = None class UserIn...256" ACCESS_TOKEN_EXPIRE_MINUTES = 30 fake_users_db = { "johndoe" : { "username" : "johndoe" , "full_name" : "John Doe" , "email" : "johndoe@example.com" , "hashed_password" : "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW" , "disabled"... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
- モデル - より詳しく 8543
- モデル - より詳しく 先ほどの例に続き、複数の関連モデルを持つことが一般的です。 これはユーザーモデルの場合は特にそうです。なぜなら: 入力モデル にはパスワードが必要です。 出力モデル はパスワードをもつべきではありません。 データベースモデル は
...かなイメージを紹介します: Python 3.8+ from typing import Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , N...one ] = None class UserOut ( BaseModel ): username : str email : EmailStr full_name : Union [ str , None ] = None class UserInDB ( BaseModel ): username : str hashed_password : str emai...l : EmailStr full_name : Union [ str , None ] = None def fake_password_hasher ( raw_password : str ): return "supersecret" + raw_pas... - https://man.mtool.work/fastapi/0.115/tutorial/extra-models/
- レスポンスモデル 8136
- レスポンスモデル path operations のいずれにおいても、 response_model パラメータを使用して、レスポンスのモデルを宣言することができます: @app.get() @app.post() @app.put() @app.delete() など。 Python 3.8+ from typing import Any , List , Union
...スワードが含まれています: Python 3.8+ from typing import Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , N...erIn : return user ? Other versions and variants Python 3.10+ from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : str | None = No...って出力を宣言しています: Python 3.8+ from typing import Union from fastapi import FastAPI from pydantic import BaseModel , EmailStr app = FastAPI () class UserIn ( BaseModel ): username : str password : str email : EmailStr full_name : Union [ str , N... - https://man.mtool.work/fastapi/0.115/tutorial/response-model/
- Generate Clients 7057
- Generate Clients Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . As FastAPI is based on the OpenAPI specification, you get automatic compatibility with many tools,
...el ): name : str price : float class ResponseMessage ( BaseModel ): message : str class User ( BaseModel ): username : str email : str @app . post ( "/items/" , response_model = ResponseMessage , tags = [ "items" ]) async def create_item ( item : Item...el ): name : str price : float class ResponseMessage ( BaseModel ): message : str class User ( BaseModel ): username : str email : str @app . post ( "/items/" , response_model = ResponseMessage , tags = [ "items" ]) async def create_item ( item : Item...el ): name : str price : float class ResponseMessage ( BaseModel ): message : str class User ( BaseModel ): username : str email : str @app . post ( "/items/" , response_model = ResponseMessage , tags = [ "items" ]) async def create_item ( item : Item... - https://man.mtool.work/fastapi/0.115/advanced/generate-clients/
- メタデータとドキュメントのURL 6668
- メタデータとドキュメントのURL FastAPI アプリケーションのいくつかのメタデータの設定をカスタマイズできます。 タイトル、説明文、バージョン 以下を設定できます: タイトル : OpenAPIおよび自動APIドキュメントUIでAPIのタイトル/名前として使用される。
...p://example.com/terms/" , contact = { "name" : "Deadpoolio the Amazing" , "url" : "http://x-force.example.com/contact/" , "email" : "dp@x-force.example.com" , }, license_info = { "name" : "Apache 2.0" , "url" : "https://www.apache.org/licenses/LICENSE... - https://man.mtool.work/fastapi/0.115/tutorial/metadata/