Results of 1 - 6 of about 6 for Invalid (0.003 sec.)
- path operationデコレータの依存関係 12338
- path operationデコレータの依存関係 場合によっては path operation関数 の中で依存関係の戻り値を本当に必要としないこともあります。 もしくは、依存関係が値を返さない場合もあります。 しかし、それでも実行・解決する必要があります。 このような場合、
...= Header ()): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def verify_key ( x_key : str = Header ()): if x_key != "fake-super-secret-key" : raise HTTPException ( status_cod...e = 400 , detail = "X-Key header invalid" ) return x_key @app . get ( "/items/" , dependencies = [ Depends ( verify_token ), Depends ( verify_key )]) async def rea...Header ()]): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def verify_key ( x_key : Annotated [ str , Header ()]): if x_key != "fake-super-secret-key" : raise HTTPException... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/dependencies-in-path-...
- テスト 10053
- テスト Starlette のおかげで、 FastAPI アプリケーションのテストは簡単で楽しいものになっています。 HTTPX がベースなので、非常に使いやすく直感的です。 これを使用すると、 FastAPI と共に pytest を直接利用できます。 TestClient を使用 TestClient を
...: str , x_token : str = Header ()): if x_token != fake_secret_token : raise HTTPException ( status_code = 400 , detail = "Invalid X-Token header" ) if item_id not in fake_db : raise HTTPException ( status_code = 404 , detail = "Item not found" ) return...: Item , x_token : str = Header ()): if x_token != fake_secret_token : raise HTTPException ( status_code = 400 , detail = "Invalid X-Token header" ) if item . id in fake_db : raise HTTPException ( status_code = 409 , detail = "Item already exists" ) fak...ken : Annotated [ str , Header ()]): if x_token != fake_secret_token : raise HTTPException ( status_code = 400 , detail = "Invalid X-Token header" ) if item_id not in fake_db : raise HTTPException ( status_code = 404 , detail = "Item not found" ) return... - https://man.mtool.work/fastapi/0.115/tutorial/testing/
- Global Dependencies 9231
- Global Dependencies Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . For some types of applications you might want to add dependencies to the whole application. Sim
...Header ()]): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def verify_key ( x_key : Annotated [ str , Header ()]): if x_key != "fake-super-secret-key" : raise HTTPException...( status_code = 400 , detail = "X-Key header invalid" ) return x_key app = FastAPI ( dependencies = [ Depends ( verify_token ), Depends ( verify_key )]) @app . get ( "/items/"...Header ()]): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def verify_key ( x_key : Annotated [ str , Header ()]): if x_key != "fake-super-secret-key" : raise HTTPException... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/global-dependencies/
- Simple OAuth2 with Password and Bearer 9139
- 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
...= fake_decode_token ( token ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user...= fake_decode_token ( token ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user...= fake_decode_token ( token ) if not user : raise HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , detail = "Invalid authentication credentials" , headers = { "WWW-Authenticate" : "Bearer" }, ) return user async def get_current_active_user... - https://man.mtool.work/fastapi/0.115/tutorial/security/simple-oauth2/
- Bigger Applications - Multiple Files 7202
- Bigger Applications - Multiple Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you are building an application or a web API, it's rarely the case that you
...Header ()]): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def get_query_token ( token : str ): if token != "jessica" : raise HTTPException ( status_code = 400 , detail = "...Header ()]): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def get_query_token ( token : str ): if token != "jessica" : raise HTTPException ( status_code = 400 , detail = "...= Header ()): if x_token != "fake-super-secret-token" : raise HTTPException ( status_code = 400 , detail = "X-Token header invalid" ) async def get_query_token ( token : str ): if token != "jessica" : raise HTTPException ( status_code = 400 , detail = "... - https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
- エラーハンドリング 6836
- エラーハンドリング APIを使用しているクライアントにエラーを通知する必要がある状況はたくさんあります。 このクライアントは、フロントエンドを持つブラウザ、誰かのコード、IoTデバイスなどが考えられます。 クライアントに以下のようなことを伝える必要が
...ndler ( RequestValidationError ) async def validation_exception_handler ( request , exc ): print ( f "OMG! The client sent invalid data!: { exc } " ) return await request_validation_exception_handler ( request , exc ) @app . get ( "/items/ {item_id} " )... - https://man.mtool.work/fastapi/0.115/tutorial/handling-errors/
PREV
1
NEXT