- Sort Score
- Result 10 results
- Languages All
Results 161 - 170 of 617 for depende (0.07 sec)
-
docs_src/dependencies/tutorial008c_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI, HTTPException app = FastAPI() class InternalError(Exception): pass def get_username(): try: yield "Rick" except InternalError: print("Oops, we didn't raise again, Britney 😱") @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id == "portal-gun":
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Feb 24 23:06:37 UTC 2024 - 700 bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_an_py310.py
from typing import Annotated from fastapi import BackgroundTasks, Depends, FastAPI app = FastAPI() def write_log(message: str): with open("log.txt", mode="a") as log: log.write(message) def get_query(background_tasks: BackgroundTasks, q: str | None = None): if q: message = f"found query: {q}\n" background_tasks.add_task(write_log, message) return q
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 683 bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_py39.py
from typing import Union from fastapi import BackgroundTasks, Depends, FastAPI app = FastAPI() def write_log(message: str): with open("log.txt", mode="a") as log: log.write(message) def get_query(background_tasks: BackgroundTasks, q: Union[str, None] = None): if q: message = f"found query: {q}\n" background_tasks.add_task(write_log, message) return q
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 675 bytes - Viewed (0) -
docs_src/dependencies/tutorial008b_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI, HTTPException app = FastAPI() data = { "plumbus": {"description": "Freshly pickled plumbus", "owner": "Morty"}, "portal-gun": {"description": "Gun to create portals", "owner": "Rick"}, } class OwnerError(Exception): pass def get_username(): try: yield "Rick" except OwnerError as e:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Tue Dec 26 20:37:34 UTC 2023 - 775 bytes - Viewed (0) -
fastapi/__init__.py
from .exceptions import WebSocketException as WebSocketException from .param_functions import Body as Body from .param_functions import Cookie as Cookie from .param_functions import Depends as Depends from .param_functions import File as File from .param_functions import Form as Form from .param_functions import Header as Header from .param_functions import Path as Path from .param_functions import Query as Query
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 15:19:50 UTC 2025 - 1.1K bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial008.py
import importlib from types import ModuleType from typing import Annotated, Any from unittest.mock import Mock, patch import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient @pytest.fixture( name="module", params=[ "tutorial008_py39", # Fails with `NameError: name 'DepA' is not defined` pytest.param("tutorial008_an_py39", marks=pytest.mark.xfail), ], )
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Dec 26 10:43:02 UTC 2025 - 1.4K bytes - Viewed (0) -
tests/test_dependency_after_yield_streaming.py
yield s def broken_dep_session() -> Any: with acquire_session() as s: s.open = False yield s SessionDep = Annotated[Session, Depends(dep_session)] BrokenSessionDep = Annotated[Session, Depends(broken_dep_session)] app = FastAPI() @app.get("/data") def get_data(session: SessionDep) -> Any: data = list(session) return data @app.get("/stream-simple")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 3.2K bytes - Viewed (0) -
docs/zh/docs/advanced/security/oauth2-scopes.md
/// {* ../../docs_src/security/tutorial005.py hl[4,139,166] *} /// info | 技术细节 `Security` 实际上是 `Depends` 的子类,而且只比 `Depends` 多一个参数。 但使用 `Security` 代替 `Depends`,**FastAPI** 可以声明安全作用域,并在内部使用这些作用域,同时,使用 OpenAPI 存档 API。 但实际上,从 `fastapi` 导入的 `Query`、`Path`、`Depends`、`Security` 等对象,只是返回特殊类的函数。 /// ## 使用 `SecurityScopes` 修改依赖项 `get_current_user`。 这是上面的依赖项使用的依赖项。Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sun Dec 29 20:41:04 UTC 2024 - 11.6K bytes - Viewed (0) -
tests/test_security_api_key_query.py
from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyQuery from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyQuery(name="key") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user @app.get("/users/me")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 1.9K bytes - Viewed (0) -
tests/test_stringified_annotation_dependency.py
from __future__ import annotations from typing import TYPE_CHECKING, Annotated import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from inline_snapshot import snapshot if TYPE_CHECKING: # pragma: no cover from collections.abc import AsyncGenerator class DummyClient: async def get_people(self) -> list: return ["John Doe", "Jane Doe"] async def close(self) -> None:Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 2.2K bytes - Viewed (0)