- Sort Score
- Num 10 results
- Language All
Results 41 - 50 of 1,598 for yield (0.02 seconds)
-
scripts/tests/test_translation_fixer/conftest.py
with runner.isolated_filesystem(): yield runner @pytest.fixture(name="root_dir") def prepare_paths(runner): docs_dir = Path("docs") en_docs_dir = docs_dir / "en" / "docs" lang_docs_dir = docs_dir / "lang" / "docs" en_docs_dir.mkdir(parents=True, exist_ok=True) lang_docs_dir.mkdir(parents=True, exist_ok=True) yield Path.cwd() @pytest.fixture
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Feb 25 10:37:59 GMT 2026 - 1.3K bytes - Click Count (0) -
docs_src/server_sent_events/tutorial005_py310.py
@app.post("/chat/stream", response_class=EventSourceResponse) async def stream_chat(prompt: Prompt) -> AsyncIterable[ServerSentEvent]: words = prompt.text.split() for word in words: yield ServerSentEvent(data=word, event="token")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 528 bytes - Click Count (0) -
docs_src/dependencies/tutorial014_an_py310.py
from sqlmodel import Field, Session, SQLModel, create_engine engine = create_engine("postgresql+psycopg://postgres:postgres@localhost/db") class User(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) name: str app = FastAPI() def get_session(): with Session(engine) as session: yield session
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Sep 29 03:29:38 GMT 2025 - 957 bytes - Click Count (0) -
docs_src/server_sent_events/tutorial002_py310.py
] @app.get("/items/stream", response_class=EventSourceResponse) async def stream_items() -> AsyncIterable[ServerSentEvent]: yield ServerSentEvent(comment="stream of item updates") for i, item in enumerate(items):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 686 bytes - Click Count (0) -
tests/test_stream_bare_type.py
class Item(BaseModel): name: str app = FastAPI() @app.get("/items/stream-bare-async") async def stream_bare_async() -> AsyncIterable: yield {"name": "foo"} @app.get("/items/stream-bare-sync") def stream_bare_sync() -> Iterable: yield {"name": "bar"} client = TestClient(app) def test_stream_bare_async_iterable(): response = client.get("/items/stream-bare-async")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 18:56:47 GMT 2026 - 1.1K bytes - Click Count (0) -
docs/ko/docs/tutorial/server-sent-events.md
/// ## FastAPI로 SSE 스트리밍 { #stream-sse-with-fastapi } FastAPI에서 SSE를 스트리밍하려면, 경로 처리 함수에서 `yield`를 사용하고 `response_class=EventSourceResponse`를 설정하세요. `EventSourceResponse`는 `fastapi.sse`에서 임포트합니다: {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[4,22] *} 각 `yield`된 항목은 JSON으로 인코딩되어 SSE 이벤트의 `data:` 필드로 전송됩니다.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:56:39 GMT 2026 - 5.3K bytes - Click Count (0) -
docs/zh/docs/tutorial/server-sent-events.md
/// ## 使用 FastAPI 流式传输 SSE { #stream-sse-with-fastapi } 要在 FastAPI 中流式传输 SSE,在你的*路径操作函数*中使用 `yield`,并设置 `response_class=EventSourceResponse`。 从 `fastapi.sse` 导入 `EventSourceResponse`: {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[4,22] *} 每个被 yield 的项会被编码为 JSON,并放入 SSE 事件的 `data:` 字段发送。 如果你将返回类型声明为 `AsyncIterable[Item]`,FastAPI 将使用它通过 Pydantic对数据进行**校验**、**文档化**和**序列化**。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:29:48 GMT 2026 - 4.6K bytes - Click Count (0) -
docs/zh-hant/docs/tutorial/server-sent-events.md
/// ## 使用 FastAPI 串流 SSE { #stream-sse-with-fastapi } 要在 FastAPI 中串流 SSE,請在你的路徑操作函式(path operation function)中使用 `yield`,並設定 `response_class=EventSourceResponse`。 從 `fastapi.sse` 匯入 `EventSourceResponse`: {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[4,22] *} 每個 `yield` 的項目都會以 JSON 編碼並放在 SSE 事件的 `data:` 欄位中送出。 如果你把回傳型別宣告為 `AsyncIterable[Item]`,FastAPI 會用它來透過 Pydantic 進行**驗證**、**文件化**與**序列化**。Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:33:04 GMT 2026 - 4.6K bytes - Click Count (0) -
docs/en/docs/tutorial/server-sent-events.md
## Stream SSE with FastAPI { #stream-sse-with-fastapi } To stream SSE with FastAPI, use `yield` in your *path operation function* and set `response_class=EventSourceResponse`. Import `EventSourceResponse` from `fastapi.sse`: {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[4,22] *} Each yielded item is encoded as JSON and sent in the `data:` field of an SSE event.Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 4.6K bytes - Click Count (0) -
docs_src/dependencies/tutorial008e_py310.py
from fastapi import Depends, FastAPI app = FastAPI() def get_username(): try: yield "Rick" finally: print("Cleanup up before response is sent") @app.get("/users/me") def get_user_me(username: str = Depends(get_username, scope="function")):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 289 bytes - Click Count (0)