Search Options

Results per page
Sort
Preferred Languages
Advance

Results 581 - 590 of 1,992 for Fastapi (0.05 sec)

  1. docs_src/app_testing/app_b_an_py310/main.py

    from typing import Annotated
    
    from fastapi import FastAPI, Header, HTTPException
    from pydantic import BaseModel
    
    fake_secret_token = "coneofsilence"
    
    fake_db = {
        "foo": {"id": "foo", "title": "Foo", "description": "There goes my hero"},
        "bar": {"id": "bar", "title": "Bar", "description": "The bartenders"},
    }
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        id: str
        title: str
        description: str | None = None
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Thu Aug 15 22:31:16 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  2. tests/test_dependency_yield_scope.py

    import json
    from typing import Annotated, Any
    
    import pytest
    from fastapi import APIRouter, Depends, FastAPI, HTTPException
    from fastapi.exceptions import FastAPIError
    from fastapi.responses import StreamingResponse
    from fastapi.testclient import TestClient
    
    
    class Session:
        def __init__(self) -> None:
            self.open = True
    
    
    def dep_session() -> Any:
        s = Session()
        yield s
        s.open = False
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 6.7K bytes
    - Viewed (0)
  3. docs/pt/docs/advanced/custom-response.md

    E será documentado como tal no OpenAPI.
    
    ///
    
    /// tip | Dica
    
    A `ORJSONResponse` está disponível apenas no FastAPI, e não no Starlette.
    
    ///
    
    ## Resposta HTML { #html-response }
    
    Para retornar uma resposta com HTML diretamente do **FastAPI**, utilize `HTMLResponse`.
    
    * Importe `HTMLResponse`
    * Passe `HTMLResponse` como o parâmetro de `response_class` do seu *decorador de operação de rota*.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 13.8K bytes
    - Viewed (0)
  4. docs/zh/docs/advanced/dataclasses.md

    6. 这行代码返回的是包含 `items` 的字典,`items` 是数据类列表;
    
        FastAPI 仍能把数据<abbr title="把数据转换为可以传输的格式">序列化</abbr>为 JSON;
    
    7. 这行代码中,`response_model` 的类型注解是 `Author` 数据类列表;
    
        再一次,可以把 `dataclasses` 与标准类型注解一起使用;
    
    8. 注意,*路径操作函数*使用的是普通函数,不是异步函数;
    
        与往常一样,在 FastAPI 中,可以按需组合普通函数与异步函数;
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 3.7K bytes
    - Viewed (0)
  5. tests/test_generic_parameterless_depends.py

    from typing import Annotated, TypeVar
    
    from fastapi import Depends, FastAPI
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    T = TypeVar("T")
    
    Dep = Annotated[T, Depends()]
    
    
    class A:
        pass
    
    
    class B:
        pass
    
    
    @app.get("/a")
    async def a(dep: Dep[A]):
        return {"cls": dep.__class__.__name__}
    
    
    @app.get("/b")
    async def b(dep: Dep[B]):
        return {"cls": dep.__class__.__name__}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.8K bytes
    - Viewed (0)
  6. docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md

    이들은 단일 `yield`가 있는 함수를 꾸미는 데 사용합니다.
    
    이것이 **FastAPI**가 `yield`가 있는 의존성을 위해 내부적으로 사용하는 방식입니다.
    
    하지만 FastAPI 의존성에는 이러한 데코레이터를 사용할 필요가 없습니다(그리고 사용해서도 안됩니다).
    
    FastAPI가 내부적으로 이를 처리해 줄 것입니다.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sun Feb 09 14:54:09 UTC 2025
    - 14.2K bytes
    - Viewed (0)
  7. tests/test_schema_compat_pydantic_v2.py

    import pytest
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    from pydantic import BaseModel
    
    from tests.utils import needs_py310
    
    
    @pytest.fixture(name="client")
    def get_client():
        from enum import Enum
    
        app = FastAPI()
    
        class PlatformRole(str, Enum):
            admin = "admin"
            user = "user"
    
        class OtherRole(str, Enum): ...
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 2.7K bytes
    - Viewed (0)
  8. docs/zh/docs/advanced/custom-response.md

    在这个例子中,HTTP 头的 `Content-Type` 会被设置成 `application/json`。
    
    并且在 OpenAPI 文档中也会这样记录。
    
    ///
    
    /// tip | 小贴士
    
    `ORJSONResponse` 目前只在 FastAPI 中可用,而在 Starlette 中不可用。
    
    ///
    
    ## HTML 响应
    
    使用 `HTMLResponse` 来从 **FastAPI** 中直接返回一个 HTML 响应。
    
    * 导入 `HTMLResponse`。
    * 将 `HTMLResponse` 作为你的 *路径操作* 的 `response_class` 参数传入。
    
    {* ../../docs_src/custom_response/tutorial002.py hl[2,7] *}
    
    /// info | 提示
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 7.5K bytes
    - Viewed (0)
  9. docs/ja/docs/advanced/response-directly.md

    /// note | 技術詳細
    
    また、`from starlette.responses import JSONResponse` も利用できます。
    
    **FastAPI** は開発者の利便性のために `fastapi.responses` という `starlette.responses` と同じものを提供しています。しかし、利用可能なレスポンスのほとんどはStarletteから直接提供されます。
    
    ///
    
    ## カスタム `Response` を返す
    
    上記の例では必要な部分を全て示していますが、あまり便利ではありません。`item` を直接返すことができるし、**FastAPI** はそれを `dict` に変換して `JSONResponse` に含めてくれるなど。すべて、デフォルトの動作です。
    
    では、これを使ってカスタムレスポンスをどう返すか見てみましょう。
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 3.6K bytes
    - Viewed (0)
  10. docs_src/custom_response/tutorial010_py39.py

    from fastapi import FastAPI
    from fastapi.responses import ORJSONResponse
    
    app = FastAPI(default_response_class=ORJSONResponse)
    
    
    @app.get("/items/")
    async def read_items():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 205 bytes
    - Viewed (0)
Back to top