Search Options

Results per page
Sort
Preferred Languages
Advance

Results 51 - 60 of 67 for txt (0.16 sec)

  1. 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)
  2. docs/en/docs/advanced/wsgi.md

    And the rest will be handled by **FastAPI**.
    
    If you run it and go to <a href="http://localhost:8000/v1/" class="external-link" target="_blank">http://localhost:8000/v1/</a> you will see the response from Flask:
    
    ```txt
    Hello, World from Flask!
    ```
    
    And if you go to <a href="http://localhost:8000/v2" class="external-link" target="_blank">http://localhost:8000/v2</a> you will see the response from FastAPI:
    
    ```JSON
    {
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:37:31 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  3. docs/zh/docs/deployment/deta.md

    def read_item(item_id: int):
        return {"item_id": item_id}
    ```
    
    ### 需求项
    
    在文件夹里新建包含如下内容的 `requirements.txt` 文件:
    
    ```text
    fastapi
    ```
    
    !!! tip "提示"
    
        在 Deta 上部署时无需安装 Uvicorn,虽然在本地测试应用时需要安装。
    
    ### 文件夹架构
    
    `./fastapideta/` 文件夹中现在有两个文件:
    
    ```
    .
    └── main.py
    └── requirements.txt
    ```
    
    ## 创建免费 Deta 账号
    
    Plain Text
    - Registered: Sun Mar 31 07:19:09 GMT 2024
    - Last Modified: Sun Jan 28 18:06:55 GMT 2024
    - 5.1K bytes
    - Viewed (0)
  4. fastapi/background.py

        ## Example
    
        ```python
        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}")
    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)
  5. docs/ja/docs/tutorial/path-params.md

      "message": "Deep Learning FTW!"
    }
    ```
    
    ## パスを含んだパスパラメータ
    
    パス `/files/{file_path}` となる *path operation* を持っているとしましょう。
    
    ただし、 `home/johndoe/myfile.txt` のような*パス*を含んだ `file_path` が必要です。
    
    したがって、URLは `/files/home/johndoe/myfile.txt` の様になります。
    
    ### OpenAPIサポート
    
    OpenAPIはテストや定義が困難なシナリオにつながる可能性があるため、内部に*パス*を含む*パスパラメータ*の宣言をサポートしていません。
    
    それにも関わらず、Starletteの内部ツールのひとつを使用することで、**FastAPI**はそれが実現できます。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  6. docs/zh/docs/contributing.md

    这样,你不必再去重新"安装"你的本地版本即可测试所有更改。
    
    !!! note "技术细节"
        仅当你使用此项目中的 `requirements.txt` 安装而不是直接使用 `pip install fastapi` 安装时,才会发生这种情况。
    
        这是因为在 `requirements.txt` 中,本地的 FastAPI 是使用“可编辑” (`-e`)选项安装的
    
    ### 格式化
    
    你可以运行下面的脚本来格式化和清理所有代码:
    
    <div class="termy">
    
    ```console
    $ bash scripts/format.sh
    ```
    
    </div>
    
    它还会自动对所有导入代码进行排序整理。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 11:57:21 GMT 2024
    - 12.9K bytes
    - Viewed (0)
  7. 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()` 标准函数与文件交互。
    
        这个函数执行 I/O(输入/输出)操作,需要等待内容写进磁盘。
    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)
  8. docs/ja/docs/tutorial/dependencies/dependencies-with-yield.md

    ```Python
    with open("./somefile.txt") as f:
        contents = f.read()
        print(contents)
    ```
    
    その後の`open("./somefile.txt")`は「コンテキストマネージャ」と呼ばれるオブジェクトを作成します。
    
    `with`ブロックが終了すると、例外があったとしてもファイルを確かに閉じます。
    
    `yield`を依存関係を作成すると、**FastAPI** は内部的にそれをコンテキストマネージャに変換し、他の関連ツールと組み合わせます。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  9. docs/en/docs/advanced/events.md

    {!../../../docs_src/events/tutorial003.py!}
    ```
    
    A **context manager** in Python is something that you can use in a `with` statement, for example, `open()` can be used as a context manager:
    
    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    In recent versions of Python, there's also an **async context manager**. You would use it with `async with`:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 7.8K bytes
    - Viewed (0)
  10. docs/ko/docs/advanced/events.md

    응용 프로그램이 종료될 때 실행하려는 함수를 추가하려면 `"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)
Back to top