Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for BackgroundTasks (0.1 sec)

  1. docs/en/docs/reference/background.md

    # Background Tasks - `BackgroundTasks`
    
    You can declare a parameter in a *path operation function* or dependency function with the type `BackgroundTasks`, and then you can use it to schedule the execution of background tasks after the response is sent.
    
    You can import it directly from `fastapi`:
    
    ```python
    from fastapi import BackgroundTasks
    ```
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:53:19 UTC 2024
    - 377 bytes
    - Viewed (0)
  2. docs/de/docs/tutorial/background-tasks.md

    ## `BackgroundTasks` verwenden
    
    Importieren Sie zunächst `BackgroundTasks` und definieren Sie einen Parameter in Ihrer *Pfadoperation-Funktion* mit der Typdeklaration `BackgroundTasks`:
    
    ```Python hl_lines="1  13"
    {!../../docs_src/background_tasks/tutorial001.py!}
    ```
    
    **FastAPI** erstellt für Sie das Objekt vom Typ `BackgroundTasks` und übergibt es als diesen Parameter.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 6.4K bytes
    - Viewed (0)
  3. docs_src/background_tasks/tutorial002_an_py310.py

    from typing import Annotated
    
    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: str | None = None):
        if q:
            message = f"found query: {q}\n"
            background_tasks.add_task(write_log, message)
        return q
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 683 bytes
    - Viewed (0)
  4. docs/pt/docs/tutorial/background-tasks.md

    ## Usando `BackgroundTasks`
    
    Primeiro, importe `BackgroundTasks` e defina um parâmetro em sua _função de operação de caminho_ com uma declaração de tipo de `BackgroundTasks`:
    
    ```Python hl_lines="1  13"
    {!../../docs_src/background_tasks/tutorial001.py!}
    ```
    
    O **FastAPI** criará o objeto do tipo `BackgroundTasks` para você e o passará como esse parâmetro.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 5.3K bytes
    - Viewed (0)
  5. docs/en/docs/tutorial/background-tasks.md

    ## Using `BackgroundTasks`
    
    First, import `BackgroundTasks` and define a parameter in your *path operation function* with a type declaration of `BackgroundTasks`:
    
    {* ../../docs_src/background_tasks/tutorial001.py hl[1,13] *}
    
    **FastAPI** will create the object of type `BackgroundTasks` for you and pass it as that parameter.
    
    ## Create a task function
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 27 15:22:48 UTC 2024
    - 4.8K bytes
    - Viewed (0)
  6. fastapi/background.py

    from typing import Any, Callable
    
    from starlette.background import BackgroundTasks as StarletteBackgroundTasks
    from typing_extensions import Annotated, Doc, ParamSpec
    
    P = ParamSpec("P")
    
    
    class BackgroundTasks(StarletteBackgroundTasks):
        """
        A collection of background tasks that will be called after a response has been
        sent to the client.
    
        Read more about it in the
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Apr 02 02:48:51 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  7. docs_src/background_tasks/tutorial002_py310.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: 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}")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 643 bytes
    - Viewed (0)
  8. docs/ru/docs/tutorial/background-tasks.md

    ## Использование класса `BackgroundTasks`
    
    Сначала импортируйте `BackgroundTasks`, потом добавьте в функцию параметр с типом `BackgroundTasks`:
    
    ```Python hl_lines="1  13"
    {!../../docs_src/background_tasks/tutorial001.py!}
    ```
    
    **FastAPI** создаст объект класса `BackgroundTasks` для вас и запишет его в параметр.
    
    ## Создание функции для фоновой задачи
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8K bytes
    - Viewed (0)
  9. docs_src/background_tasks/tutorial002.py

    from typing import Union
    
    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
    
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 675 bytes
    - Viewed (0)
  10. docs/fr/docs/tutorial/background-tasks.md

    
    ## Utiliser `BackgroundTasks`
    
    Pour commencer, importez `BackgroundTasks` et définissez un paramètre dans votre *fonction de chemin* avec `BackgroundTasks` comme type déclaré.
    
    {* ../../docs_src/background_tasks/tutorial001.py hl[1,13] *}
    
    **FastAPI** créera l'objet de type `BackgroundTasks` pour vous et le passera comme paramètre.
    
    ## Créer une fonction de tâche
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Mon Oct 28 10:29:51 UTC 2024
    - 5.6K bytes
    - Viewed (0)
Back to top