- Sort Score
- Result 10 results
- Languages All
Results 1 - 5 of 5 for FixedContentQueryChecker (0.2 sec)
-
docs_src/dependencies/tutorial011_an_py39.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/")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 544 bytes - Viewed (0) -
docs_src/dependencies/tutorial011_py39.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/")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 504 bytes - Viewed (0) -
docs/zh/docs/advanced/advanced-dependencies.md
## 创建实例 使用以下代码创建类实例: {* ../../docs_src/dependencies/tutorial011.py hl[16] *} 这样就可以**参数化**依赖项,它包含 `checker.fixed_content` 的属性 - `"bar"`。 ## 把实例作为依赖项 然后,不要再在 `Depends(checker)` 中使用 `Depends(FixedContentQueryChecker)`, 而是要使用 `checker`,因为依赖项是类实例 - `checker`,不是类。 处理依赖项时,**FastAPI** 以如下方式调用 `checker`: ```Python checker(q="somequery") ``` ……并用*路径操作函数*的参数 `fixed_content_included` 返回依赖项的值:Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 18 02:25:44 UTC 2024 - 1.9K bytes - Viewed (0) -
docs/ko/docs/advanced/advanced-dependencies.md
다음과 같이 이 클래스의 인스턴스를 생성할 수 있습니다: {* ../../docs_src/dependencies/tutorial011_an_py39.py hl[18] *} 이렇게 하면 `checker.fixed_content` 속성에 `"bar"`라는 값을 담아 의존성을 "매개변수화"할 수 있습니다. ## 인스턴스를 의존성으로 사용하기 그런 다음, `Depends(FixedContentQueryChecker)` 대신 `Depends(checker)`에서 이 `checker` 인스턴스를 사용할 수 있으며, 클래스 자체가 아닌 인스턴스 `checker`가 의존성이 됩니다. 의존성을 해결할 때 **FastAPI**는 이 `checker`를 다음과 같이 호출합니다: ```Python checker(q="somequery") ```Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 18 02:25:44 UTC 2024 - 2.9K bytes - Viewed (0) -
docs/en/docs/advanced/advanced-dependencies.md
## Use the instance as a dependency { #use-the-instance-as-a-dependency } Then, we could use this `checker` in a `Depends(checker)`, instead of `Depends(FixedContentQueryChecker)`, because the dependency is the instance, `checker`, not the class itself. And when solving the dependency, **FastAPI** will call this `checker` like: ```Python checker(q="somequery") ```Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Thu Nov 13 07:37:15 UTC 2025 - 9.1K bytes - Viewed (0)