- Sort Score
- Result 10 results
- Languages All
Results 381 - 390 of 1,379 for def2 (0.02 sec)
-
docs_src/dependencies/tutorial005_py310.py
from fastapi import Cookie, Depends, FastAPI app = FastAPI() def query_extractor(q: str | None = None): return q def query_or_cookie_extractor( q: str = Depends(query_extractor), last_query: 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)):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 443 bytes - Viewed (0) -
tests/test_tutorial/test_testing/test_tutorial001.py
from docs_src.app_testing.tutorial001 import client, test_read_main def test_main(): test_read_main() def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text assert response.json() == { "openapi": "3.1.0", "info": {"title": "FastAPI", "version": "0.1.0"}, "paths": { "/": { "get": {
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 821 bytes - Viewed (0) -
tests/test_tutorial/test_handling_errors/test_tutorial005.py
} ], "body": {"title": "towel", "size": "XL"}, } ) def test_post(): data = {"title": "towel", "size": 5} response = client.post("/items/", json=data) assert response.status_code == 200, response.text assert response.json() == data def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 4.3K bytes - Viewed (0) -
tests/test_tutorial/test_header_params/test_tutorial003_an_py39.py
], ) def test(path, headers, expected_status, expected_response, client: TestClient): response = client.get(path, headers=headers) assert response.status_code == expected_status assert response.json() == expected_response @needs_py39 def test_openapi_schema(client: TestClient): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.3K bytes - Viewed (0) -
tests/test_tutorial/test_schema_extra_example/test_tutorial001_py310.py
from fastapi.testclient import TestClient from ...utils import needs_py310, needs_pydanticv2 @pytest.fixture(name="client") def get_client(): from docs_src.schema_extra_example.tutorial001_py310 import app client = TestClient(app) return client @needs_py310 @needs_pydanticv2 def test_post_body_example(client: TestClient): response = client.put( "/items/5", json={
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.7K bytes - Viewed (0) -
docs_src/dependencies/tutorial011_an.py
app = FastAPI() class FixedContentQueryChecker: def __init__(self, fixed_content: str): self.fixed_content = fixed_content def __call__(self, q: str = ""): if q: return self.fixed_content in q return False checker = FixedContentQueryChecker("bar") @app.get("/query-checker/") async def read_query_check(fixed_content_included: Annotated[bool, Depends(checker)]):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 554 bytes - Viewed (0) -
tests/test_tutorial/test_wsgi/test_tutorial001.py
from fastapi.testclient import TestClient from docs_src.wsgi.tutorial001 import app client = TestClient(app) def test_flask(): response = client.get("/v1/") assert response.status_code == 200, response.text assert response.text == "Hello, World from Flask!" def test_app(): response = client.get("/v2") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Jul 09 18:06:12 UTC 2020 - 436 bytes - Viewed (0) -
docs_src/dependencies/tutorial005.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)):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat May 14 11:59:59 UTC 2022 - 486 bytes - Viewed (0) -
docs_src/dependencies/tutorial005_an_py310.py
from fastapi import Cookie, Depends, FastAPI app = FastAPI() def query_extractor(q: str | None = None): return q def query_or_cookie_extractor( q: Annotated[str, Depends(query_extractor)], last_query: Annotated[str | None, Cookie()] = None, ): if not q: return last_query return q @app.get("/items/") async def read_query(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 510 bytes - Viewed (0) -
docs_src/dependencies/tutorial001_02_an_py310.py
from fastapi import Depends, FastAPI app = FastAPI() async def common_parameters(q: 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/") async def read_users(commons: CommonsDep):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 447 bytes - Viewed (0)