Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 11 of 11 for notes (0.13 sec)

  1. docs/zh/docs/async.md

    results = await some_library()
    ```
    
    然后,通过 `async def` 声明你的 *路径操作函数*:
    
    ```Python hl_lines="2"
    @app.get('/')
    async def read_results():
        results = await some_library()
        return results
    ```
    
    !!! note
        你只能在被 `async def` 创建的函数内使用 `await`
    
    ---
    
    如果你正在使用一个第三方库和某些组件(比如:数据库、API、文件系统...)进行通信,第三方库又不支持使用 `await` (目前大多数数据库三方库都是这样),这种情况你可以像平常那样使用 `def` 声明一个路径操作函数,就像这样:
    
    ```Python hl_lines="2"
    @app.get('/')
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 21.1K bytes
    - Viewed (0)
Back to top