Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 241 - 250 of 795 for asyncId (0.3 seconds)

  1. docs_src/events/tutorial003_py310.py

        return x * 42
    
    
    ml_models = {}
    
    
    @asynccontextmanager
    async def lifespan(app: FastAPI):
        # Load the ML model
        ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model
        yield
        # Clean up the ML models and release the resources
        ml_models.clear()
    
    
    app = FastAPI(lifespan=lifespan)
    
    
    @app.get("/predict")
    async def predict(x: float):
        result = ml_models["answer_to_everything"](x)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 569 bytes
    - Click Count (0)
  2. tests/test_dependency_contextvars.py

    )
    
    app = FastAPI()
    
    
    async def set_up_request_state_dependency():
        request_state = {"user": "deadpond"}
        contextvar_token = legacy_request_state_context_var.set(request_state)
        yield request_state
        legacy_request_state_context_var.reset(contextvar_token)
    
    
    @app.middleware("http")
    async def custom_middleware(
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  3. docs/zh-hant/docs/advanced/dataclasses.md

    7. 這裡 `response_model` 使用的是「`Author` dataclass 的清單」這種型別註記。
    
       同樣地,你可以把 `dataclasses` 與標準型別註記組合使用。
    8. 注意這個「路徑操作函式」使用的是一般的 `def` 而非 `async def`。
    
       一如往常,在 FastAPI 中你可以視需要混用 `def` 與 `async def`。
    
       如果需要複習何時用哪個,請參考文件中關於 [`async` 與 `await`](../async.md#in-a-hurry) 的章節「In a hurry?」。
    9. 這個「路徑操作函式」回傳的不是 dataclass(雖然也可以),而是一個包含內部資料的字典清單。
    
       FastAPI 會使用 `response_model` 參數(其中包含 dataclass)來轉換回應。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 3.8K bytes
    - Click Count (0)
  4. docs/fr/docs/tutorial/request-files.md

        - C'est particulièrement utile si vous exécutez `await myfile.read()` une fois puis devez relire le contenu.
    - `close()` : ferme le fichier.
    
    Comme toutes ces méthodes sont `async`, vous devez les « await ».
    
    Par exemple, à l'intérieur d'une *fonction de chemin d'accès* `async`, vous pouvez obtenir le contenu avec :
    
    ```Python
    contents = await myfile.read()
    ```
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:37:13 GMT 2026
    - 8.2K bytes
    - Click Count (0)
  5. docs/es/docs/tutorial/request-files.md

    * `close()`: Cierra el archivo.
    
    Como todos estos métodos son métodos `async`, necesitas "await" para ellos.
    
    Por ejemplo, dentro de una *path operation function* `async` puedes obtener los contenidos con:
    
    ```Python
    contents = await myfile.read()
    ```
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:15:55 GMT 2026
    - 7.6K bytes
    - Click Count (0)
  6. tests/test_request_params/test_path/test_required_str.py

    from fastapi.testclient import TestClient
    from inline_snapshot import Is, snapshot
    
    app = FastAPI()
    
    
    @app.get("/required-str/{p}")
    async def read_required_str(p: Annotated[str, Path()]):
        return {"p": p}
    
    
    @app.get("/required-alias/{p_alias}")
    async def read_required_alias(p: Annotated[str, Path(alias="p_alias")]):
        return {"p": p}
    
    
    @app.get("/required-validation-alias/{p_val_alias}")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Mon Feb 09 15:35:43 GMT 2026
    - 2.4K bytes
    - Click Count (0)
  7. tests/test_stringified_annotation_dependency_py314.py

    
    @needs_py314
    def test_stringified_annotation():
        # python3.14: Use forward reference without "from __future__ import annotations"
        async def get_current_user() -> DummyUser | None:
            return None
    
        app = FastAPI()
    
        client = TestClient(app)
    
        @app.get("/")
        async def get(
            current_user: Annotated[DummyUser | None, Depends(get_current_user)],
        ) -> str:
            return "hello world"
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 04 13:49:44 GMT 2026
    - 711 bytes
    - Click Count (0)
  8. docs_src/security/tutorial002_py310.py

    def fake_decode_token(token):
        return User(
            username=token + "fakedecoded", email="******@****.***", full_name="John Doe"
        )
    
    
    async def get_current_user(token: str = Depends(oauth2_scheme)):
        user = fake_decode_token(token)
        return user
    
    
    @app.get("/users/me")
    async def read_users_me(current_user: User = Depends(get_current_user)):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 711 bytes
    - Click Count (0)
  9. docs_src/security/tutorial002_an_py310.py

        return User(
            username=token + "fakedecoded", email="******@****.***", full_name="John Doe"
        )
    
    
    async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):
        user = fake_decode_token(token)
        return user
    
    
    @app.get("/users/me")
    async def read_users_me(current_user: Annotated[User, Depends(get_current_user)]):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 761 bytes
    - Click Count (0)
  10. docs/tr/docs/tutorial/server-sent-events.md

    ///
    
    ### Async Olmayan Path Operation Fonksiyonları { #non-async-path-operation-functions }
    
    Normal `def` fonksiyonlarını (yani `async` olmadan) da kullanabilir ve aynı şekilde `yield` kullanabilirsiniz.
    
    FastAPI, event loop'u bloke etmeyecek şekilde doğru biçimde çalışmasını sağlar.
    
    Bu örnekte fonksiyon async olmadığı için doğru dönüş tipi `Iterable[Item]` olur:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:51:35 GMT 2026
    - 5.1K bytes
    - Click Count (0)
Back to Top