Search Options

Results per page
Sort
Preferred Languages
Advance

Results 531 - 540 of 1,127 for def2 (0.04 sec)

  1. tests/test_tutorial/test_response_model/test_tutorial005.py

    from docs_src.response_model.tutorial005 import app
    
    client = TestClient(app)
    
    
    def test_read_item_name():
        response = client.get("/items/bar/name")
        assert response.status_code == 200, response.text
        assert response.json() == {"name": "Bar", "description": "The Bar fighters"}
    
    
    def test_read_item_public_data():
        response = client.get("/items/bar/public")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 04 20:47:07 UTC 2023
    - 6K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_response_model/test_tutorial006.py

    from docs_src.response_model.tutorial006 import app
    
    client = TestClient(app)
    
    
    def test_read_item_name():
        response = client.get("/items/bar/name")
        assert response.status_code == 200, response.text
        assert response.json() == {"name": "Bar", "description": "The Bar fighters"}
    
    
    def test_read_item_public_data():
        response = client.get("/items/bar/public")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 04 20:47:07 UTC 2023
    - 6K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_request_files/test_tutorial001_03.py

    client = TestClient(app)
    
    
    def test_post_file(tmp_path):
        path = tmp_path / "test.txt"
        path.write_bytes(b"<file content>")
    
        client = TestClient(app)
        with path.open("rb") as file:
            response = client.post("/files/", files={"file": file})
        assert response.status_code == 200, response.text
        assert response.json() == {"file_size": 14}
    
    
    def test_post_upload_file(tmp_path):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 6K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_dependencies/test_tutorial004_an_py39.py

                200,
                {"items": [{"item_name": "Bar"}], "q": "bar"},
            ),
        ],
    )
    def test_get(path, expected_status, expected_response, client: TestClient):
        response = client.get(path)
        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
    - 5.6K bytes
    - Viewed (0)
  5. docs_src/custom_response/tutorial009c.py

    app = FastAPI()
    
    
    class CustomORJSONResponse(Response):
        media_type = "application/json"
    
        def render(self, content: Any) -> bytes:
            assert orjson is not None, "orjson must be installed"
            return orjson.dumps(content, option=orjson.OPT_INDENT_2)
    
    
    @app.get("/", response_class=CustomORJSONResponse)
    async def main():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Sep 01 09:32:30 UTC 2022
    - 451 bytes
    - Viewed (0)
  6. docs_src/request_files/tutorial001_03_an_py39.py

    from typing import Annotated
    
    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]):
        return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(
        file: Annotated[UploadFile, File(description="A file read as UploadFile")],
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 421 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial003.py

    from docs_src.path_operation_advanced_configuration.tutorial003 import app
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.get("/items/")
        assert response.status_code == 200, response.text
        assert response.json() == [{"item_id": "Foo"}]
    
    
    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
    - 575 bytes
    - Viewed (0)
  8. docs/fr/docs/tutorial/background-tasks.md

    Elle peut être une fonction asynchrone (`async def`) ou une fonction normale (`def`), **FastAPI** saura la gérer correctement.
    
    Dans cet exemple, la fonction de tâche écrira dans un fichier (afin de simuler un envoi d'email).
    
    L'opération d'écriture n'utilisant ni `async` ni `await`, on définit la fonction avec un `def` normal.
    
    {* ../../docs_src/background_tasks/tutorial001.py hl[6:9] *}
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Oct 28 10:29:51 UTC 2024
    - 5.6K bytes
    - Viewed (0)
  9. tests/test_orjson_response_class.py

    from sqlalchemy.sql.elements import quoted_name
    
    app = FastAPI(default_response_class=ORJSONResponse)
    
    
    @app.get("/orjson_non_str_keys")
    def get_orjson_non_str_keys():
        key = quoted_name(value="msg", quote=False)
        return {key: "Hello World", 1: 1}
    
    
    client = TestClient(app)
    
    
    def test_orjson_non_str_keys():
        with client:
            response = client.get("/orjson_non_str_keys")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Sep 02 10:17:31 UTC 2022
    - 562 bytes
    - Viewed (0)
  10. docs_src/response_model/tutorial001_01_py310.py

        name: str
        description: str | None = None
        price: float
        tax: float | None = None
        tags: list[str] = []
    
    
    @app.post("/items/")
    async def create_item(item: Item) -> Item:
        return item
    
    
    @app.get("/items/")
    async def read_items() -> list[Item]:
        return [
            Item(name="Portal Gun", price=42.0),
            Item(name="Plumbus", price=32.0),
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jan 07 13:45:48 UTC 2023
    - 469 bytes
    - Viewed (0)
Back to top