- Sort Score
- Num 10 results
- Language All
Results 91 - 100 of 653 for depende (0.04 seconds)
-
docs_src/security/tutorial004_an_py39.py
async def get_current_active_user( current_user: Annotated[User, Depends(get_current_user)], ): if current_user.disabled: raise HTTPException(status_code=400, detail="Inactive user") return current_user @app.post("/token") async def login_for_access_token( form_data: Annotated[OAuth2PasswordRequestForm, Depends()], ) -> Token:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Mon Sep 29 02:57:38 GMT 2025 - 4.2K bytes - Click Count (0) -
docs_src/security/tutorial005_py310.py
from datetime import datetime, timedelta, timezone import jwt from fastapi import Depends, FastAPI, HTTPException, Security, status from fastapi.security import ( OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, ) from jwt.exceptions import InvalidTokenError from pwdlib import PasswordHash from pydantic import BaseModel, ValidationError # to get a string like this run: # openssl rand -hex 32
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Mon Sep 29 02:57:38 GMT 2025 - 5.2K bytes - Click Count (0) -
fastapi/security/http.py
```python from typing import Annotated from fastapi import Depends, FastAPI from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() @app.get("/users/me") def read_current_user(credentials: Annotated[HTTPBasicCredentials, Depends(security)]): return {"username": credentials.username, "password": credentials.password}Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 13.2K 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_src/dependency_testing/tutorial001_py39.py
from typing import Union from fastapi import Depends, FastAPI from fastapi.testclient import TestClient 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: dict = Depends(common_parameters)): return {"message": "Hello Items!", "params": commons}
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 1.5K bytes - Click Count (0) -
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi_simple.py
) async def get_token(token: Annotated[str, Depends(oauth2_scheme)]) -> str: return token app = FastAPI(dependencies=[Depends(get_token)]) @app.get("/admin", dependencies=[Security(get_token, scopes=["read", "write"])]) async def read_admin(): return {"message": "Admin Access"} client = TestClient(app) def test_read_admin():
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 2.6K bytes - Click Count (0) -
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) -
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/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) -
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)