Search Options

Results per page
Sort
Preferred Languages
Advance

Results 421 - 430 of 1,379 for def2 (0.03 sec)

  1. docs_src/dependencies/tutorial003.py

    
    fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
    
    
    class CommonQueryParams:
        def __init__(self, q: Union[str, None] = None, skip: int = 0, limit: int = 100):
            self.q = q
            self.skip = skip
            self.limit = limit
    
    
    @app.get("/items/")
    async def read_items(commons=Depends(CommonQueryParams)):
        response = {}
        if commons.q:
            response.update({"q": commons.q})
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 635 bytes
    - Viewed (0)
  2. docs_src/dependencies/tutorial004_an_py310.py

    
    fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
    
    
    class CommonQueryParams:
        def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100):
            self.q = q
            self.skip = skip
            self.limit = limit
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[CommonQueryParams, Depends()]):
        response = {}
        if commons.q:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 647 bytes
    - Viewed (0)
  3. tests/test_tutorial/test_custom_request_and_route/test_tutorial001.py

    from docs_src.custom_request_and_route.tutorial001 import app
    
    
    @app.get("/check-class")
    async def check_gzip_request(request: Request):
        return {"request_class": type(request).__name__}
    
    
    client = TestClient(app)
    
    
    @pytest.mark.parametrize("compress", [True, False])
    def test_gzip_request(compress):
        n = 1000
        headers = {}
        body = [1] * n
        data = json.dumps(body).encode()
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Nov 13 14:26:09 UTC 2022
    - 886 bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial002_an_py39.py

    
    fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
    
    
    class CommonQueryParams:
        def __init__(self, q: Union[str, None] = None, skip: int = 0, limit: int = 100):
            self.q = q
            self.skip = skip
            self.limit = limit
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]):
        response = {}
        if commons.q:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 677 bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial003_an_py39.py

    
    fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}]
    
    
    class CommonQueryParams:
        def __init__(self, q: Union[str, None] = None, skip: int = 0, limit: int = 100):
            self.q = q
            self.skip = skip
            self.limit = limit
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[Any, Depends(CommonQueryParams)]):
        response = {}
        if commons.q:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 668 bytes
    - Viewed (0)
  6. tests/test_fastapi_cli.py

    import subprocess
    import sys
    from unittest.mock import patch
    
    import fastapi.cli
    import pytest
    
    
    def test_fastapi_cli():
        result = subprocess.run(
            [
                sys.executable,
                "-m",
                "coverage",
                "run",
                "-m",
                "fastapi",
                "dev",
                "non_existent_file.py",
            ],
            capture_output=True,
            encoding="utf-8",
        )
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 02 06:03:05 UTC 2024
    - 790 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_custom_response/test_tutorial006.py

    from docs_src.custom_response.tutorial006 import app
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.get("/typer", follow_redirects=False)
        assert response.status_code == 307, response.text
        assert response.headers["location"] == "https://typer.tiangolo.com"
    
    
    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: Fri Jun 30 18:25:16 UTC 2023
    - 1K bytes
    - Viewed (0)
  8. tests/test_typing_python39.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    
    from .utils import needs_py310
    
    
    @needs_py310
    def test_typing():
        types = {
            list[int]: [1, 2, 3],
            dict[str, list[int]]: {"a": [1, 2, 3], "b": [4, 5, 6]},
            set[int]: [1, 2, 3],  # `set` is converted to `list`
            tuple[int, ...]: [1, 2, 3],  # `tuple` is converted to `list`
        }
        for test_type, expect in types.items():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 709 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_path_operation_configurations/test_tutorial005_py310.py

    from ...utils import needs_py310, needs_pydanticv1, needs_pydanticv2
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.path_operation_configuration.tutorial005_py310 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    def test_query_params_str_validations(client: TestClient):
        response = client.post("/items/", json={"name": "Foo", "price": 42})
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Sep 28 04:14:40 UTC 2023
    - 8.9K bytes
    - Viewed (0)
  10. docs_src/bigger_applications/app_an/routers/items.py

        responses={404: {"description": "Not found"}},
    )
    
    
    fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}}
    
    
    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 1011 bytes
    - Viewed (0)
Back to top