Results of 1 - 10 of about 10 for else (0.009 sec.)
- OAuth2 scopes 13372
- 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
...| None = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to_encode . update ({ "exp" : expire }) encoded_...auth2_scheme )] ): if security_scopes . scopes : authenticate_value = f 'Bearer scope=" { security_scopes . scope_str } "' else : authenticate_value = "Bearer" credentials_exception = HTTPException ( status_code = status . HTTP_401_UNAUTHORIZED , det...None ] = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to_encode . update ({ "exp" : expire }) encoded_... - https://man.mtool.work/fastapi/0.115/advanced/security/oauth2-scopes/
- Request Files 10029
- Request Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can define files to be uploaded by the client using File . Info To receive uploaded files, first
...def create_file ( file : Annotated [ bytes | None , File ()] = None ): if not file : return { "message" : "No file sent" } else : return { "file_size" : len ( file )} @app . post ( "/uploadfile/" ) async def create_upload_file ( file : UploadFile | N...one = None ): if not file : return { "message" : "No upload file sent" } else : return { "filename" : file . filename } ? Other versions and variants Python 3.9+ Python 3.8+ Python 3.10+ - non-Annotat...e_file ( file : Annotated [ Union [ bytes , None ], File ()] = None ): if not file : return { "message" : "No file sent" } else : return { "file_size" : len ( file )} @app . post ( "/uploadfile/" ) async def create_upload_file ( file : Union [ Upload... - https://man.mtool.work/fastapi/0.115/tutorial/request-files/
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer 9779
- パスワード(およびハッシュ化)によるOAuth2、JWTトークンによるBearer これでセキュリティの流れが全てわかったので、 JWT トークンと安全なパスワードのハッシュ化を使用して、実際にアプリケーションを安全にしてみましょう。 このコードは、アプリケーシ
...None ] = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to_encode . update ({ "exp" : expire }) encoded_...| None = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to_encode . update ({ "exp" : expire }) encoded_...None ] = None ): to_encode = data . copy () if expires_delta : expire = datetime . now ( timezone . utc ) + expires_delta else : expire = datetime . now ( timezone . utc ) + timedelta ( minutes = 15 ) to_encode . update ({ "exp" : expire }) encoded_... - https://man.mtool.work/fastapi/0.115/tutorial/security/oauth2-jwt/
- 追加のステータスコード 9528
- 追加のステータスコード デフォルトでは、 FastAPI は JSONResponse を使ってレスポンスを返します。その JSONResponse の中には、 path operation が返した内容が入ります。 それは、デフォルトのステータスコードか、 path operation でセットしたものを利用
...ault = None ), ): if item_id in items : item = items [ item_id ] item [ "name" ] = name item [ "size" ] = size return item else : item = { "name" : name , "size" : size } items [ item_id ] = item return JSONResponse ( status_code = status . HTTP_201_...y ()] = None , ): if item_id in items : item = items [ item_id ] item [ "name" ] = name item [ "size" ] = size return item else : item = { "name" : name , "size" : size } items [ item_id ] = item return JSONResponse ( status_code = status . HTTP_201_...y ()] = None , ): if item_id in items : item = items [ item_id ] item [ "name" ] = name item [ "size" ] = size return item else : item = { "name" : name , "size" : size } items [ item_id ] = item return JSONResponse ( status_code = status . HTTP_201_... - https://man.mtool.work/fastapi/0.115/advanced/additional-status-codes/
- Configure Swagger UI 8616
- Configure Swagger UI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can configure some extra Swagger UI parameters . To configure them, pass the swagger_ui_pa
...qp, arr; if (/code|token|error/.test(window.location.hash)) { qp = window.location.hash.substring(1).replace('?', '&'); } else { qp = location.search.substring(1); } arr = qp.split("&"); arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=...code) { delete oauth2.state; oauth2.auth.code = qp.code; oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl}); } else { let oauthErrorMsg; if (qp.error) { oauthErrorMsg = "["+qp.error+"]: " + (qp.error_description ? qp.error_description+ "....auth", level: "error", message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server." }); } } else { oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl}); } window.close(); } if (doc... - https://man.mtool.work/fastapi/0.115/how-to/configure-swagger-ui/
- Additional Responses in OpenAPI 8366
- 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
...m_id : str , img : Union [ bool , None ] = None ): if img : 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 FileRespo...}, ) 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 and includ...m_id : str , img : Union [ bool , None ] = None ): if img : return FileResponse ( "image.png" , media_type = "image/png" ) else : return { "id" : "foo" , "value" : "there goes my hero" } More information about OpenAPI responses To see what exactly yo... - https://man.mtool.work/fastapi/0.115/advanced/additional-responses/
- Async Tests 7615
- Async Tests Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You have already seen how to test your FastAPI applications using the provided TestClient . Up to now,
...c functions apart from sending requests to your FastAPI application in your tests, exactly as you would call them anywhere else in your code. Tip If you encounter a RuntimeError: Task attached to a different loop when integrating asynchronous functio... - https://man.mtool.work/fastapi/0.115/advanced/async-tests/
- Behind a Proxy 7365
- Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration
...tion to Uvicorn or Hypercorn. About root_path Keep in mind that the server (Uvicorn) won't use that root_path for anything else than passing it to the app. But if you go with your browser to http://127.0.0.1:8000/app you will see the normal response:... - https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
- OpenAPI Callbacks 7365
- OpenAPI Callbacks Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You could create an API with a path operation that could trigger a request to an external API cre
...ated by someone else (probably the same developer that would be using your API). The process that happens when your API app calls the external... - https://man.mtool.work/fastapi/0.115/advanced/openapi-callbacks/
- Pythonの型の紹介 7276
- Pythonの型の紹介 Python 3.6以降 では「型ヒント」オプションがサポートされています。 これらの "型ヒント" は変数の 型 を宣言することができる新しい構文です。(Python 3.6以降) 変数に型を宣言することでエディターやツールがより良いサポートを提供す
...m typing import Optional def say_hi ( name : Optional [ str ] = None ): if name is not None : print ( f "Hey { name } !" ) else : print ( "Hello World" ) ただの str の代わりに Optional[str] を使用することで、エディタは値が常に str であると仮定している... - https://man.mtool.work/fastapi/0.115/python-types/
PREV
1
NEXT