- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 15 for __call__ (0.17 sec)
-
tests/test_dependency_class.py
class CallableDependency: def __call__(self, value: str) -> str: return value class CallableGenDependency: def __call__(self, value: str) -> Generator[str, None, None]: yield value class AsyncCallableDependency: async def __call__(self, value: str) -> str: return value class AsyncCallableGenDependency: async def __call__(self, value: str) -> AsyncGenerator[str, None]:
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Sun Aug 09 10:54:05 GMT 2020 - 3.3K bytes - Viewed (0) -
docs/zh/docs/advanced/advanced-dependencies.md
假设要创建校验查询参数 `q` 是否包含固定内容的依赖项。 但此处要把待检验的固定内容定义为参数。 ## **可调用**实例 Python 可以把类实例变为**可调用项**。 这里说的不是类本身(类本就是可调用项),而是类实例。 为此,需要声明 `__call__` 方法: ```Python hl_lines="10" {!../../../docs_src/dependencies/tutorial011.py!} ``` 本例中,**FastAPI** 使用 `__call__` 检查附加参数及子依赖项,稍后,还要调用它向*路径操作函数*传递值。 ## 参数化实例 接下来,使用 `__init__` 声明用于**参数化**依赖项的实例参数: ```Python hl_lines="7"
Plain Text - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Sun Jan 28 18:26:57 GMT 2024 - 2K bytes - Viewed (0) -
fastapi/security/http.py
): self.model = HTTPBaseModel(scheme=scheme, description=description) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error async def __call__( self, request: Request ) -> Optional[HTTPAuthorizationCredentials]: authorization = request.headers.get("Authorization") scheme, credentials = get_authorization_scheme_param(authorization)
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Tue Oct 24 20:26:06 GMT 2023 - 13.2K bytes - Viewed (0) -
docs/em/docs/advanced/advanced-dependencies.md
✋️ 👥 💚 💪 🔗 👈 🔧 🎚. ## "🇧🇲" 👐 🐍 📤 🌌 ⚒ 👐 🎓 "🇧🇲". 🚫 🎓 ⚫️ (❔ ⏪ 🇧🇲), ✋️ 👐 👈 🎓. 👈, 👥 📣 👩🔬 `__call__`: ```Python hl_lines="10" {!../../../docs_src/dependencies/tutorial011.py!} ``` 👉 💼, 👉 `__call__` ⚫️❔ **FastAPI** 🔜 ⚙️ ✅ 🌖 🔢 & 🎧-🔗, & 👉 ⚫️❔ 🔜 🤙 🚶♀️ 💲 🔢 👆 *➡ 🛠️ 🔢* ⏪. ## 🔗 👐 & 🔜, 👥 💪 ⚙️ `__init__` 📣 🔢 👐 👈 👥 💪 ⚙️ "🔗" 🔗:
Plain Text - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Sat Apr 01 09:26:04 GMT 2023 - 2K bytes - Viewed (0) -
fastapi/security/api_key.py
name=name, description=description, ) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error async def __call__(self, request: Request) -> Optional[str]: api_key = request.query_params.get(self.model.name) if not api_key: if self.auto_error: raise HTTPException(
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Wed Oct 18 12:36:40 GMT 2023 - 9.2K bytes - Viewed (0) -
docs_src/dependencies/tutorial011.py
from fastapi import Depends, FastAPI app = FastAPI() class FixedContentQueryChecker: def __init__(self, fixed_content: str): self.fixed_content = fixed_content def __call__(self, q: str = ""): if q: return self.fixed_content in q return False checker = FixedContentQueryChecker("bar") @app.get("/query-checker/")
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Thu Mar 26 19:09:53 GMT 2020 - 504 bytes - Viewed (0) -
docs_src/dependencies/tutorial011_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI app = FastAPI() class FixedContentQueryChecker: def __init__(self, fixed_content: str): self.fixed_content = fixed_content def __call__(self, q: str = ""): if q: return self.fixed_content in q return False checker = FixedContentQueryChecker("bar") @app.get("/query-checker/")
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 544 bytes - Viewed (0) -
docs_src/dependencies/tutorial011_an.py
from typing_extensions import Annotated app = FastAPI() class FixedContentQueryChecker: def __init__(self, fixed_content: str): self.fixed_content = fixed_content def __call__(self, q: str = ""): if q: return self.fixed_content in q return False checker = FixedContentQueryChecker("bar") @app.get("/query-checker/")
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 554 bytes - Viewed (0) -
docs/en/docs/advanced/advanced-dependencies.md
## A "callable" instance In Python there's a way to make an instance of a class a "callable". Not the class itself (which is already a callable), but an instance of that class. To do that, we declare a method `__call__`: === "Python 3.9+" ```Python hl_lines="12" {!> ../../../docs_src/dependencies/tutorial011_an_py39.py!} ``` === "Python 3.8+" ```Python hl_lines="11"
Plain Text - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Tue Oct 17 05:59:11 GMT 2023 - 3.9K bytes - Viewed (0) -
fastapi/security/open_id_connect_url.py
openIdConnectUrl=openIdConnectUrl, description=description ) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error async def __call__(self, request: Request) -> Optional[str]: authorization = request.headers.get("Authorization") if not authorization: if self.auto_error: raise HTTPException(
Python - Registered: Sun Mar 24 07:19:08 GMT 2024 - Last Modified: Thu Mar 14 16:38:24 GMT 2024 - 2.7K bytes - Viewed (0)