- Sort Score
- Result 10 results
- Languages All
Results 21 - 30 of 36 for log (0.12 sec)
-
tests/test_tutorial/test_background_tasks/test_tutorial002_an_py39.py
client = TestClient(app) log = Path("log.txt") if log.is_file(): os.remove(log) # pragma: no cover response = client.post("/send-notification/******@****.***?q=some-query") assert response.status_code == 200, response.text assert response.json() == {"message": "Message sent"} with open("./log.txt") as f:
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 628 bytes - Viewed (0) -
docs/fr/docs/tutorial/background-tasks.md
``` Dans cet exemple, les messages seront écrits dans le fichier `log.txt` après que la réponse soit envoyée. S'il y avait une `query` (paramètre nommé `q`) dans la requête, alors elle sera écrite dans `log.txt` via une tâche d'arrière-plan. Et ensuite une autre tâche d'arrière-plan (générée dans les paramètres de la *la fonction de chemin*) écrira un message dans `log.txt` comprenant le paramètre de chemin `email`. ## Détails techniques
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Thu May 12 00:06:16 GMT 2022 - 5.7K bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_an_py39.py
from fastapi import BackgroundTasks, Depends, FastAPI app = FastAPI() def write_log(message: str): with open("log.txt", mode="a") as log: log.write(message) def get_query(background_tasks: BackgroundTasks, q: Union[str, None] = None): if q: message = f"found query: {q}\n" background_tasks.add_task(write_log, message) return q @app.post("/send-notification/{email}")
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 696 bytes - Viewed (0) -
docs_src/background_tasks/tutorial001.py
from fastapi import BackgroundTasks, FastAPI app = FastAPI() def write_notification(email: str, message=""): with open("log.txt", mode="w") as email_file: content = f"notification for {email}: {message}" email_file.write(content) @app.post("/send-notification/{email}") async def send_notification(email: str, background_tasks: BackgroundTasks):
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Thu Mar 26 19:09:53 GMT 2020 - 519 bytes - Viewed (0) -
docs/ru/docs/tutorial/background-tasks.md
```Python hl_lines="13 15 22 25" {!> ../../../docs_src/background_tasks/tutorial002.py!} ``` В этом примере сообщения будут записаны в `log.txt` *после* того, как ответ сервера был отправлен. Если бы в запрос был передан query-параметр `q`, он бы первыми записался в `log.txt` фоновой задачей (потому что вызывается в зависимости `get_query`).
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Jan 09 15:52:07 GMT 2024 - 8K bytes - Viewed (0) -
docs/zh/docs/advanced/events.md
只有所有 `startup` 事件处理器运行完毕,**FastAPI** 应用才开始接收请求。 ## `shutdown` 事件 使用 `shutdown` 事件声明 `app` 关闭时运行的函数: ```Python hl_lines="6" {!../../../docs_src/events/tutorial002.py!} ``` 此处,`shutdown` 事件处理器函数在 `log.txt` 中写入一行文本 `Application shutdown`。 !!! info "说明" `open()` 函数中,`mode="a"` 指的是**追加**。因此这行文本会添加在文件已有内容之后,不会覆盖之前的内容。 !!! tip "提示" 注意,本例使用 Python `open()` 标准函数与文件交互。
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Thu Apr 18 19:53:19 GMT 2024 - 1.7K bytes - Viewed (0) -
docs/en/docs/tutorial/background-tasks.md
```Python hl_lines="13 15 22 25" {!> ../../../docs_src/background_tasks/tutorial002.py!} ``` In this example, the messages will be written to the `log.txt` file *after* the response is sent. If there was a query in the request, it will be written to the log in a background task. And then another background task generated at the *path operation function* will write a message using the `email` path parameter.
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Oct 17 05:59:11 GMT 2023 - 5.6K bytes - Viewed (0) -
docs/ko/docs/advanced/events.md
## `shutdown` 이벤트 응용 프로그램이 종료될 때 실행하려는 함수를 추가하려면 `"shutdown"` 이벤트로 선언합니다: ```Python hl_lines="6" {!../../../docs_src/events/tutorial002.py!} ``` 이 예제에서 `shutdown` 이벤트 핸들러 함수는 `"Application shutdown"`이라는 텍스트가 적힌 `log.txt` 파일을 추가할 것입니다. !!! info "정보" `open()` 함수에서 `mode="a"`는 "추가"를 의미합니다. 따라서 이미 존재하는 파일의 내용을 덮어쓰지 않고 새로운 줄을 추가합니다. !!! tip "팁" 이 예제에서는 파일과 상호작용 하기 위해 파이썬 표준 함수인 `open()`을 사용하고 있습니다.
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Apr 02 22:35:55 GMT 2024 - 2.2K bytes - Viewed (0) -
fastapi/background.py
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Apr 02 02:48:51 GMT 2024 - 1.7K bytes - Viewed (0) -
docs/en/docs/tutorial/handling-errors.md
Plain Text - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Fri Mar 22 01:42:11 GMT 2024 - 9.1K bytes - Viewed (0)