Search Options

Results per page
Sort
Preferred Languages
Advance

Results 161 - 170 of 877 for tutorial002 (0.13 sec)

  1. docs/en/docs/advanced/response-headers.md

    And then you can set headers in that *temporal* response object.
    
    ```Python hl_lines="1  7-8"
    {!../../docs_src/response_headers/tutorial002.py!}
    ```
    
    And then you can return any object you need, as you normally would (a `dict`, a database model, etc).
    
    And if you declared a `response_model`, it will still be used to filter and convert the object you returned.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 2.2K bytes
    - Viewed (0)
  2. docs/zh/docs/advanced/events.md

    使用 `startup` 事件声明 `app` 启动前运行的函数:
    
    ```Python hl_lines="8"
    {!../../docs_src/events/tutorial001.py!}
    ```
    
    本例中,`startup` 事件处理器函数为项目数据库(只是**字典**)提供了一些初始值。
    
    **FastAPI** 支持多个事件处理器函数。
    
    只有所有 `startup` 事件处理器运行完毕,**FastAPI** 应用才开始接收请求。
    
    ## `shutdown` 事件
    
    使用 `shutdown` 事件声明 `app` 关闭时运行的函数:
    
    ```Python hl_lines="6"
    {!../../docs_src/events/tutorial002.py!}
    ```
    
    此处,`shutdown` 事件处理器函数在 `log.txt` 中写入一行文本 `Application shutdown`。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  3. docs/pt/docs/tutorial/path-params-numeric-validations.md

    ```Python hl_lines="8"
    {!../../docs_src/path_params_numeric_validations/tutorial004.py!}
    ```
    
    ## Validações numéricas: maior que e menor que ou igual
    
    O mesmo se aplica para:
    
    * `gt`: maior que (`g`reater `t`han)
    * `le`: menor que ou igual (`l`ess than or `e`qual)
    
    ```Python hl_lines="9"
    {!../../docs_src/path_params_numeric_validations/tutorial005.py!}
    ```
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 5.6K bytes
    - Viewed (0)
  4. docs/fr/docs/tutorial/query-params.md

    ## Paramètres optionnels
    
    De la même façon, vous pouvez définir des paramètres de requête comme optionnels, en leur donnant comme valeur par défaut `None` :
    
    {* ../../docs_src/query_params/tutorial002.py hl[9] *}
    
    Ici, le paramètre `q` sera optionnel, et aura `None` comme valeur par défaut.
    
    /// check | "Remarque"
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 27 17:06:01 UTC 2024
    - 5.6K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_additional_responses/test_tutorial002.py

    import os
    import shutil
    
    from dirty_equals import IsDict
    from fastapi.testclient import TestClient
    
    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():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 4.6K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_separate_openapi_schemas/test_tutorial002.py

    import pytest
    from fastapi.testclient import TestClient
    
    from ...utils import needs_pydanticv2
    
    
    @pytest.fixture(name="client")
    def get_client() -> TestClient:
        from docs_src.separate_openapi_schemas.tutorial002 import app
    
        client = TestClient(app)
        return client
    
    
    def test_create_item(client: TestClient) -> None:
        response = client.post("/items/", json={"name": "Foo"})
        assert response.status_code == 200, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 25 19:10:22 UTC 2023
    - 4.8K bytes
    - Viewed (0)
  7. docs/de/docs/advanced/middleware.md

    ```Python hl_lines="2  6"
    {!../../docs_src/advanced_middleware/tutorial001.py!}
    ```
    
    ## `TrustedHostMiddleware`
    
    Erzwingt, dass alle eingehenden Requests einen korrekt gesetzten `Host`-Header haben, um sich vor HTTP-Host-Header-Angriffen zu schützen.
    
    ```Python hl_lines="2  6-8"
    {!../../docs_src/advanced_middleware/tutorial002.py!}
    ```
    
    Die folgenden Argumente werden unterstützt:
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 4.3K bytes
    - Viewed (0)
  8. docs/em/docs/advanced/dataclasses.md

    ✋️ 🚥 👆 ✔️ 📚 🎻 🤥 🤭, 👉 👌 🎱 ⚙️ 👫 🏋️ 🕸 🛠️ ⚙️ FastAPI. 👶
    
    ///
    
    ## 🎻 `response_model`
    
    👆 💪 ⚙️ `dataclasses` `response_model` 🔢:
    
    ```Python hl_lines="1  7-13  19"
    {!../../docs_src/dataclasses/tutorial002.py!}
    ```
    
    🎻 🔜 🔁 🗜 Pydantic 🎻.
    
    👉 🌌, 🚮 🔗 🔜 🎦 🆙 🛠️ 🩺 👩‍💻 🔢:
    
    <img src="/img/tutorial/dataclasses/image01.png">
    
    ## 🎻 🔁 📊 📊
    
    👆 💪 🌀 `dataclasses` ⏮️ 🎏 🆎 ✍ ⚒ 🐦 📊 📊.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.4K bytes
    - Viewed (0)
  9. docs/pt/docs/tutorial/schema-extra-example.md

    Você pode usar isso para adicionar um `example` para cada campo:
    
    ```Python hl_lines="4  10-13"
    {!../../docs_src/schema_extra_example/tutorial002.py!}
    ```
    
    /// warning | "Atenção"
    
    Lembre-se de que esses argumentos extras passados ​​não adicionarão nenhuma validação, apenas informações extras, para fins de documentação.
    
    ///
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  10. docs/zh/docs/advanced/dataclasses.md

    因此,开发时仍需要使用 Pydantic 模型。
    
    但如果数据类很多,这一技巧能给 FastAPI 开发 Web API 增添不少助力。🤓
    
    ///
    
    ## `response_model` 使用数据类
    
    在 `response_model` 参数中使用 `dataclasses`:
    
    ```Python hl_lines="1  7-13  19"
    {!../../docs_src/dataclasses/tutorial002.py!}
    ```
    
    本例把数据类自动转换为 Pydantic 数据类。
    
    API 文档中也会显示相关概图:
    
    <img src="/img/tutorial/dataclasses/image01.png">
    
    ## 在嵌套数据结构中使用数据类
    
    您还可以把 `dataclasses` 与其它类型注解组合在一起,创建嵌套数据结构。
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.7K bytes
    - Viewed (0)
Back to top