- Sort Score
- Result 10 results
- Languages All
Results 81 - 90 of 617 for depende (0.05 sec)
-
docs_src/security/tutorial002_an_py310.py
) async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]): user = fake_decode_token(token) return user @app.get("/users/me") async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 761 bytes - Viewed (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,
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 406 bytes - Viewed (0) -
docs_src/dependencies/tutorial012_an_py39.py
app = FastAPI(dependencies=[Depends(verify_token), Depends(verify_key)]) @app.get("/items/") async def read_items(): return [{"item": "Portal Gun"}, {"item": "Plumbus"}] @app.get("/users/") async def read_users():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 746 bytes - Viewed (0) -
docs_src/dependencies/tutorial012_py39.py
from fastapi import Depends, FastAPI, Header, HTTPException async def verify_token(x_token: str = Header()): if x_token != "fake-super-secret-token": raise HTTPException(status_code=400, detail="X-Token header invalid") async def verify_key(x_key: str = Header()): if x_key != "fake-super-secret-key": raise HTTPException(status_code=400, detail="X-Key header invalid") return x_key
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 696 bytes - Viewed (0) -
docs_src/security/tutorial007_an_py39.py
import secrets from typing import Annotated from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() def get_current_username( credentials: Annotated[HTTPBasicCredentials, Depends(security)], ): current_username_bytes = credentials.username.encode("utf8") correct_username_bytes = b"stanleyjobson"
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 1.1K bytes - Viewed (0) -
tests/test_dependency_duplicates.py
@app.post("/with-duplicates") async def with_duplicates(item: Item, item2: Item = Depends(duplicate_dependency)): return [item, item2] @app.post("/no-duplicates") async def no_duplicates(item: Item, item2: Item = Depends(dependency)): return [item, item2] @app.post("/with-duplicates-sub") async def no_duplicates_sub( item: Item, sub_items: list[Item] = Depends(sub_duplicate_dependency) ): return [item, sub_items]
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 8K bytes - Viewed (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
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 455 bytes - Viewed (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/")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 466 bytes - Viewed (0) -
docs_src/dependencies/tutorial014_an_py310.py
def get_user(user_id: int, session: Annotated[Session, Depends(get_session)]): user = session.get(User, user_id) if not user: raise HTTPException(status_code=403, detail="Not authorized") session.close() def generate_stream(query: str): for ch in query: yield ch time.sleep(0.1) @app.get("/generate", dependencies=[Depends(get_user)]) def generate(query: str):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Sep 29 03:29:38 UTC 2025 - 957 bytes - Viewed (0) -
tests/test_security_scopes.py
return "user" app = FastAPI() @app.get("/") def endpoint( db: Annotated[str, Depends(get_db)], user: Annotated[str, Security(get_user, scopes=["read"])], ): return {"db": db} return app @pytest.fixture(name="client") def client_fixture(app: FastAPI): return TestClient(app) def test_security_scopes_dependency_called_once(
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1006 bytes - Viewed (0)