Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 131 - 140 of 1,038 for Async (0.02 seconds)

  1. tests/test_request_params/test_form/test_optional_list.py

    
    @app.post("/optional-list-str", operation_id="optional_list_str")
    async def read_optional_list_str(
        p: Annotated[list[str] | None, Form()] = None,
    ):
        return {"p": p}
    
    
    class FormModelOptionalListStr(BaseModel):
        p: list[str] | None = None
    
    
    @app.post("/model-optional-list-str", operation_id="model_optional_list_str")
    async def read_model_optional_list_str(p: Annotated[FormModelOptionalListStr, Form()]):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 9.9K bytes
    - Click Count (0)
  2. fastapi/security/api_key.py

        ```python
        from fastapi import Depends, FastAPI
        from fastapi.security import APIKeyQuery
    
        app = FastAPI()
    
        query_scheme = APIKeyQuery(name="api_key")
    
    
        @app.get("/items/")
        async def read_items(api_key: str = Depends(query_scheme)):
            return {"api_key": api_key}
        ```
        """
    
        def __init__(
            self,
            *,
            name: Annotated[
                str,
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 9.6K bytes
    - Click Count (1)
  3. tests/test_request_params/test_form/test_optional_str.py

    # Without aliases
    
    
    @app.post("/optional-str", operation_id="optional_str")
    async def read_optional_str(p: Annotated[str | None, Form()] = None):
        return {"p": p}
    
    
    class FormModelOptionalStr(BaseModel):
        p: str | None = None
    
    
    @app.post("/model-optional-str", operation_id="model_optional_str")
    async def read_model_optional_str(p: Annotated[FormModelOptionalStr, Form()]):
        return {"p": p.p}
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 8.9K bytes
    - Click Count (0)
  4. tests/test_request_params/test_query/test_required_str.py

    # =====================================================================================
    # Without aliases
    
    
    @app.get("/required-str")
    async def read_required_str(p: str):
        return {"p": p}
    
    
    class QueryModelRequiredStr(BaseModel):
        p: str
    
    
    @app.get("/model-required-str")
    async def read_model_required_str(p: Annotated[QueryModelRequiredStr, Query()]):
        return {"p": p.p}
    
    
    @pytest.mark.parametrize(
        "path",
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 10.2K bytes
    - Click Count (0)
  5. docs_src/app_testing/app_b_an_py310/main.py

    @app.get("/items/{item_id}", response_model=Item)
    async def read_main(item_id: str, x_token: Annotated[str, Header()]):
        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item_id not in fake_db:
            raise HTTPException(status_code=404, detail="Item not found")
        return fake_db[item_id]
    
    
    @app.post("/items/")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 04 13:32:24 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  6. docs_src/app_testing/tutorial004_py310.py

    from fastapi.testclient import TestClient
    
    items = {}
    
    
    @asynccontextmanager
    async def lifespan(app: FastAPI):
        items["foo"] = {"name": "Fighters"}
        items["bar"] = {"name": "Tenders"}
        yield
        # clean up items
        items.clear()
    
    
    app = FastAPI(lifespan=lifespan)
    
    
    @app.get("/items/{item_id}")
    async def read_items(item_id: str):
        return items[item_id]
    
    
    def test_read_items():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 1.2K bytes
    - Click Count (0)
  7. docs/ja/docs/tutorial/dependencies/index.md

    これは **大規模なコードベース** で、**同じ依存関係** を **多くの *path operation*** で何度も使う場合に特に役立ちます。
    
    ## `async`にするかどうか { #to-async-or-not-to-async }
    
    依存関係は **FastAPI**(*path operation 関数*と同じ)からも呼び出されるため、関数を定義する際にも同じルールが適用されます。
    
    `async def`や通常の`def`を使用することができます。
    
    また、通常の`def`*path operation 関数*の中に`async def`を入れて依存関係を宣言したり、`async def`*path operation 関数*の中に`def`を入れて依存関係を宣言したりすることなどができます。
    
    それは重要ではありません。**FastAPI** は何をすべきかを知っています。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 11.9K bytes
    - Click Count (0)
  8. tests/test_request_params/test_file/test_optional.py

    # Without aliases
    
    
    @app.post("/optional-bytes", operation_id="optional_bytes")
    async def read_optional_bytes(p: Annotated[bytes | None, File()] = None):
        return {"file_size": len(p) if p else None}
    
    
    @app.post("/optional-uploadfile", operation_id="optional_uploadfile")
    async def read_optional_uploadfile(p: Annotated[UploadFile | None, File()] = None):
        return {"file_size": p.size if p else None}
    
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Feb 21 13:01:31 GMT 2026
    - 9.8K bytes
    - Click Count (0)
  9. tests/test_request_params/test_query/test_optional_list.py

    # Without aliases
    
    
    @app.get("/optional-list-str")
    async def read_optional_list_str(
        p: Annotated[list[str] | None, Query()] = None,
    ):
        return {"p": p}
    
    
    class QueryModelOptionalListStr(BaseModel):
        p: list[str] | None = None
    
    
    @app.get("/model-optional-list-str")
    async def read_model_optional_list_str(
        p: Annotated[QueryModelOptionalListStr, Query()],
    ):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 9.4K bytes
    - Click Count (0)
  10. tests/test_response_model_data_filter.py

        name: str
        owner: UserDB
    
    
    class PetOut(BaseModel):
        name: str
        owner: UserBase
    
    
    @app.post("/users/", response_model=UserBase)
    async def create_user(user: UserCreate):
        return user
    
    
    @app.get("/pets/{pet_id}", response_model=PetOut)
    async def read_pet(pet_id: int):
        user = UserDB(
            email="******@****.***",
            hashed_password="secrethashed",
        )
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 1.7K bytes
    - Click Count (0)
Back to Top