- Sort Score
- Result 10 results
- Languages All
Results 161 - 170 of 1,379 for def2 (0.15 sec)
-
docs_src/background_tasks/tutorial002_an.py
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 @app.post("/send-notification/{email}") async def send_notification(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 725 bytes - Viewed (0) -
docs_src/security/tutorial002_an_py39.py
disabled: Union[bool, None] = None def fake_decode_token(token): return User( username=token + "fakedecoded", email="******@****.***", full_name="John Doe" ) 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 Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 786 bytes - Viewed (0) -
docs_src/extra_models/tutorial002.py
class UserIn(UserBase): password: str class UserOut(UserBase): pass class UserInDB(UserBase): hashed_password: str def fake_password_hasher(raw_password: str): return "supersecret" + raw_password def fake_save_user(user_in: UserIn): hashed_password = fake_password_hasher(user_in.password) user_in_db = UserInDB(**user_in.dict(), hashed_password=hashed_password)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat May 14 11:59:59 UTC 2022 - 824 bytes - Viewed (0) -
tests/test_tutorial/test_sub_applications/test_tutorial001.py
} } }, "servers": [{"url": "/subapi"}], } def test_openapi_schema_main(): response = client.get("/openapi.json") assert response.status_code == 200, response.text assert response.json() == openapi_schema_main def test_main(): response = client.get("/app") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1.9K bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_02_an_py310.py
from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.request_files.tutorial001_02_an_py310 import app client = TestClient(app) return client @needs_py310 def test_post_form_no_body(client: TestClient): response = client.post("/files/") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 8.5K bytes - Viewed (0) -
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an.py
import pytest from dirty_equals import IsDict from fastapi.testclient import TestClient @pytest.fixture(name="client") def get_client(): from docs_src.body_multiple_params.tutorial003_an import app client = TestClient(app) return client def test_post_body_valid(client: TestClient): response = client.put( "/items/5", json={ "importance": 2,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 9.4K bytes - Viewed (0) -
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an_py310.py
from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.body_multiple_params.tutorial003_an_py310 import app client = TestClient(app) return client @needs_py310 def test_post_body_valid(client: TestClient): response = client.put( "/items/5", json={ "importance": 2,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 9.5K bytes - Viewed (0) -
tests/test_tutorial/test_body_multiple_params/test_tutorial003_an_py39.py
from dirty_equals import IsDict from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="client") def get_client(): from docs_src.body_multiple_params.tutorial003_an_py39 import app client = TestClient(app) return client @needs_py39 def test_post_body_valid(client: TestClient): response = client.put( "/items/5", json={ "importance": 2,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 9.5K bytes - Viewed (0) -
tests/test_security_api_key_cookie_optional.py
api_key = APIKeyCookie(name="key", auto_error=False) class User(BaseModel): username: str def get_current_user(oauth_header: Optional[str] = Security(api_key)): if oauth_header is None: return None user = User(username=oauth_header) return user @app.get("/users/me") def read_current_user(current_user: User = Depends(get_current_user)): if current_user is None:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.1K bytes - Viewed (0) -
tests/test_security_api_key_query_optional.py
api_key = APIKeyQuery(name="key", auto_error=False) class User(BaseModel): username: str def get_current_user(oauth_header: Optional[str] = Security(api_key)): if oauth_header is None: return None user = User(username=oauth_header) return user @app.get("/users/me") def read_current_user(current_user: Optional[User] = Depends(get_current_user)): if current_user is None:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2K bytes - Viewed (0)