- Sort Score
- Result 10 results
- Languages All
Results 341 - 350 of 871 for tutorial001 (0.16 sec)
-
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 Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 1.7K bytes - Viewed (0) -
docs/de/docs/advanced/response-headers.md
```Python hl_lines="10-12" {!../../docs_src/response_headers/tutorial001.py!} ``` /// note | "Technische Details" Sie können auch `from starlette.responses import Response` oder `from starlette.responses import JSONResponse` verwenden.
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.6K bytes - Viewed (0) -
docs/en/docs/advanced/response-headers.md
Create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank} and pass the headers as an additional parameter: ```Python hl_lines="10-12" {!../../docs_src/response_headers/tutorial001.py!} ``` /// note | "Technical Details" You could also use `from starlette.responses import Response` or `from starlette.responses import JSONResponse`.
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.2K bytes - Viewed (0) -
docs/pt/docs/tutorial/dependencies/index.md
``` //// //// tab | Python 3.8+ non-Annotated /// tip | "Dica" Utilize a versão com `Annotated` se possível. /// ```Python hl_lines="8-11" {!> ../../docs_src/dependencies/tutorial001.py!} ``` //// E pronto. **2 linhas**. E com a mesma forma e estrutura de todas as suas *funções de operação de rota*.
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 12.6K bytes - Viewed (0) -
tests/test_tutorial/test_templates/test_tutorial001.py
shutil.rmtree("./templates") shutil.copytree("./docs_src/templates/templates/", "./templates") shutil.copytree("./docs_src/templates/static/", "./static") from docs_src.templates.tutorial001 import app client = TestClient(app) response = client.get("/items/foo") assert response.status_code == 200, response.text assert (
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Thu Jan 11 22:25:37 UTC 2024 - 910 bytes - Viewed (0) -
docs/zh/docs/advanced/dataclasses.md
但 FastAPI 还可以使用数据类(<a href="https://docs.python.org/3/library/dataclasses.html" class="external-link" target="_blank">`dataclasses`</a>): ```Python hl_lines="1 7-12 19-20" {!../../docs_src/dataclasses/tutorial001.py!} ``` 这还是借助于 **Pydantic** 及其<a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/#use-of-stdlib-dataclasses-with-basemodel" class="external-link" target="_blank">内置的 `dataclasses`</a>。
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 3.7K bytes - Viewed (0) -
docs/zh/docs/tutorial/middleware.md
* 一个函数 `call_next` 它将接收 `request` 作为参数. * 这个函数将 `request` 传递给相应的 *路径操作*. * 然后它将返回由相应的*路径操作*生成的 `response`. * 然后你可以在返回 `response` 前进一步修改它. ```Python hl_lines="8-9 11 14" {!../../docs_src/middleware/tutorial001.py!} ``` /// tip 请记住可以 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">用'X-' 前缀</a>添加专有自定义请求头.
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.7K bytes - Viewed (0) -
docs/en/docs/advanced/response-change-status-code.md
And then you can set the `status_code` in that *temporal* response object. ```Python hl_lines="1 9 12" {!../../docs_src/response_change_status_code/tutorial001.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 Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 1.5K bytes - Viewed (0) -
tests/test_tutorial/test_separate_openapi_schemas/test_tutorial001.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.tutorial001 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 Oct 27 07:19:11 UTC 2024 - Last Modified: Thu Sep 28 04:14:40 UTC 2023 - 4.8K bytes - Viewed (0) -
docs/ko/docs/advanced/events.md
```Python hl_lines="8" {!../../docs_src/events/tutorial001.py!} ``` 이 경우 `startup` 이벤트 핸들러 함수는 단순히 몇 가지 값으로 구성된 `dict` 형식의 "데이터베이스"를 초기화합니다. 하나 이상의 이벤트 핸들러 함수를 추가할 수도 있습니다. 그리고 응용 프로그램은 모든 `startup` 이벤트 핸들러가 완료될 때까지 요청을 받지 않습니다. ## `shutdown` 이벤트 응용 프로그램이 종료될 때 실행하려는 함수를 추가하려면 `"shutdown"` 이벤트로 선언합니다: ```Python hl_lines="6" {!../../docs_src/events/tutorial002.py!} ```
Registered: Sun Oct 27 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.2K bytes - Viewed (0)