- Sort Score
- Num 10 results
- Language All
Results 301 - 310 of 1,555 for depend (0.04 seconds)
-
docs_src/dependency_testing/tutorial001_py310.py
from fastapi import Depends, FastAPI from fastapi.testclient import TestClient app = FastAPI() async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: dict = Depends(common_parameters)): return {"message": "Hello Items!", "params": commons} @app.get("/users/")
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 1.4K bytes - Click Count (0) -
tests/test_dependency_after_yield_websockets.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.websocket("/ws") async def websocket_endpoint(websocket: WebSocket, session: SessionDep): await websocket.accept()
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 2K bytes - Click Count (0) -
docs_src/security/tutorial003_py310.py
async def get_current_user(token: str = Depends(oauth2_scheme)): user = fake_decode_token(token) if not user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, ) return user async def get_current_active_user(current_user: User = Depends(get_current_user)): if current_user.disabled:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Mon Nov 24 19:03:06 GMT 2025 - 2.4K bytes - Click Count (0) -
docs_src/dependencies/tutorial008_py39.py
from fastapi import Depends async def dependency_a(): dep_a = generate_dep_a() try: yield dep_a finally: dep_a.close() async def dependency_b(dep_a=Depends(dependency_a)): dep_b = generate_dep_b() try: yield dep_b finally: dep_b.close(dep_a) async def dependency_c(dep_b=Depends(dependency_b)): dep_c = generate_dep_c() try: yield dep_c
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 455 bytes - Click Count (0) -
docs_src/dependencies/tutorial005_py39.py
from fastapi import Cookie, Depends, FastAPI app = FastAPI() def query_extractor(q: Union[str, None] = None): return q def query_or_cookie_extractor( q: str = Depends(query_extractor), last_query: Union[str, None] = Cookie(default=None), ): if not q: return last_query return q @app.get("/items/") async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 486 bytes - Click Count (0) -
docs_src/dependencies/tutorial001_an_py39.py
from typing import Annotated, Union from fastapi import Depends, FastAPI app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: Annotated[dict, Depends(common_parameters)]): return commons @app.get("/users/")
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 473 bytes - Click Count (0) -
tests/test_security_scopes_sub_dependency.py
def get_user_items( user_me: Annotated[dict, Depends(get_user_me)], ): call_counts["get_user_items"] += 1 return { "user_items": f"user_items_{call_counts['get_user_items']}", "user_me": user_me, } app = FastAPI() @app.get("/") def path_operation( user_me: Annotated[dict, Depends(get_user_me)],Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 2.9K bytes - Click Count (0) -
docs_src/settings/app02_py39/main.py
from functools import lru_cache from fastapi import Depends, FastAPI from .config import Settings app = FastAPI() @lru_cache def get_settings(): return Settings() @app.get("/info") async def info(settings: Settings = Depends(get_settings)): return { "app_name": settings.app_name, "admin_email": settings.admin_email, "items_per_user": settings.items_per_user,
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 406 bytes - Click Count (0) -
docs/en/docs/tutorial/dependencies/index.md
Although you use `Depends` in the parameters of your function the same way you use `Body`, `Query`, etc, `Depends` works a bit differently. You only give `Depends` a single parameter. This parameter must be something like a function. You **don't call it** directly (don't add the parenthesis at the end), you just pass it as a parameter to `Depends()`. And that function takes parameters in the same way that *path operation functions* do.
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sun Aug 31 09:15:41 GMT 2025 - 9.6K bytes - Click Count (0) -
docs_src/dependencies/tutorial001_02_an_py39.py
from typing import Annotated, Union from fastapi import Depends, FastAPI app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} CommonsDep = Annotated[dict, Depends(common_parameters)] @app.get("/items/") async def read_items(commons: CommonsDep): return commons @app.get("/users/")
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 466 bytes - Click Count (0)