- Sort Score
- Result 10 results
- Languages All
Results 281 - 290 of 1,379 for def2 (0.03 sec)
-
docs_src/handling_errors/tutorial003.py
from fastapi import FastAPI, Request from fastapi.responses import JSONResponse class UnicornException(Exception): def __init__(self, name: str): self.name = name app = FastAPI() @app.exception_handler(UnicornException) async def unicorn_exception_handler(request: Request, exc: UnicornException): return JSONResponse( status_code=418,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 626 bytes - Viewed (0) -
tests/test_tutorial/test_additional_responses/test_tutorial002.py
from docs_src.additional_responses.tutorial002 import app client = TestClient(app) def test_path_operation(): response = client.get("/items/foo") assert response.status_code == 200, response.text assert response.json() == {"id": "foo", "value": "there goes my hero"} def test_path_operation_img(): shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.6K bytes - Viewed (0) -
docs/em/docs/advanced/async-tests.md
β‘οΈ π β π₯ πͺ β π π·. ## pytest.mark.anyio π₯ π₯ π π€ π π’ π π―, π π― π’ βοΈ π. AnyIO π π π π, π β π₯ β π π― π’ π€ π. ## πΈπ² π₯ π **FastAPI** πΈ βοΈ π `def` π’ β©οΈ `async def`, β«οΈ `async` πΈ π. `TestClient` π¨ π± π π€ π FastAPI πΈ π π `def` π― π’, βοΈ π© β³. βοΈ π π± π« π· π«π πβ π₯ βοΈ β«οΈ π π π’. π π π― π, π₯ πͺ π ββ π βοΈ `TestClient` π π π― π’.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 3K bytes - Viewed (0) -
docs_src/path_operation_configuration/tutorial002_py39.py
tags: set[str] = set() @app.post("/items/", response_model=Item, tags=["items"]) async def create_item(item: Item): return item @app.get("/items/", tags=["items"]) async def read_items(): return [{"name": "Foo", "price": 42}] @app.get("/users/", tags=["users"]) async def read_users():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat May 14 11:59:59 UTC 2022 - 575 bytes - Viewed (0) -
tests/test_security_api_key_header_optional.py
api_key = APIKeyHeader(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) -
tests/test_security_http_digest_optional.py
security = HTTPDigest(auto_error=False) @app.get("/users/me") def read_current_user( credentials: Optional[HTTPAuthorizationCredentials] = Security(security), ): if credentials is None: return {"msg": "Create an account first"} return {"scheme": credentials.scheme, "credentials": credentials.credentials} client = TestClient(app) def test_security_http_digest():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.2K bytes - Viewed (0) -
tests/test_tutorial/test_request_form_models/test_tutorial001_an.py
import pytest from dirty_equals import IsDict from fastapi.testclient import TestClient @pytest.fixture(name="client") def get_client(): from docs_src.request_form_models.tutorial001_an import app client = TestClient(app) return client def test_post_body_form(client: TestClient): response = client.post("/login/", data={"username": "Foo", "password": "secret"}) assert response.status_code == 200
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Sep 05 15:16:50 UTC 2024 - 7.4K bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial008b_an.py
from fastapi.testclient import TestClient from docs_src.dependencies.tutorial008b_an import app client = TestClient(app) def test_get_no_item(): response = client.get("/items/foo") assert response.status_code == 404, response.text assert response.json() == {"detail": "Item not found"} def test_owner_error(): response = client.get("/items/plumbus") assert response.status_code == 400, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Dec 26 20:37:34 UTC 2023 - 700 bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_an_py310.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: 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 - 683 bytes - Viewed (0) -
tests/test_openapi_route_extensions.py
app = FastAPI() @app.get("/", openapi_extra={"x-custom-extension": "value"}) def route_with_extras(): return {} client = TestClient(app) def test_get_route(): response = client.get("/") assert response.status_code == 200, response.text assert response.json() == {} def test_openapi(): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1.1K bytes - Viewed (0)