- Sort Score
- Num 10 results
- Language All
Results 121 - 130 of 1,038 for Async (0.04 seconds)
-
docs/en/docs/advanced/dataclasses.md
8. Notice that this *path operation function* uses regular `def` instead of `async def`. As always, in FastAPI you can combine `def` and `async def` as needed. If you need a refresher about when to use which, check out the section _"In a hurry?"_ in the docs about [`async` and `await`](../async.md#in-a-hurry).Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 4K bytes - Click Count (0) -
docs_src/custom_request_and_route/tutorial002_an_py310.py
from fastapi.routing import APIRoute class ValidationErrorLoggingRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response: try: return await original_route_handler(request) except RequestValidationError as exc: body = await request.body()
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 974 bytes - Click Count (0) -
fastapi/exception_handlers.py
{"detail": exc.detail}, status_code=exc.status_code, headers=headers ) async def request_validation_exception_handler( request: Request, exc: RequestValidationError ) -> JSONResponse: return JSONResponse( status_code=422, content={"detail": jsonable_encoder(exc.errors())}, ) async def websocket_request_validation_exception_handler(Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Sep 16 17:21:48 GMT 2025 - 1.2K bytes - Click Count (0) -
docs_src/request_files/tutorial003_py310.py
from fastapi.responses import HTMLResponse app = FastAPI() @app.post("/files/") async def create_files( files: list[bytes] = File(description="Multiple files as bytes"), ): return {"file_sizes": [len(file) for file in files]} @app.post("/uploadfiles/") async def create_upload_files( files: list[UploadFile] = File(description="Multiple files as UploadFile"), ):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 888 bytes - Click Count (0) -
tests/test_security_scopes_dont_propagate.py
from fastapi import FastAPI, Security from fastapi.security import SecurityScopes from fastapi.testclient import TestClient async def security1(scopes: SecurityScopes): return scopes.scopes async def security2(scopes: SecurityScopes): return scopes.scopes async def dep3( dep1: Annotated[list[str], Security(security1, scopes=["scope1"])],
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 973 bytes - Click Count (0) -
docs_src/security/tutorial003_an_py310.py
return user async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]): user = fake_decode_token(token) if not user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Not authenticated", headers={"WWW-Authenticate": "Bearer"}, ) return user async def get_current_active_user(
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Nov 24 19:03:06 GMT 2025 - 2.5K bytes - Click Count (0) -
docs_src/body_updates/tutorial001_py310.py
"baz": {"name": "Baz", "description": None, "price": 50.2, "tax": 10.5, "tags": []}, } @app.get("/items/{item_id}", response_model=Item) async def read_item(item_id: str): return items[item_id] @app.put("/items/{item_id}", response_model=Item) async def update_item(item_id: str, item: Item): update_item_encoded = jsonable_encoder(item) items[item_id] = update_item_encoded
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Jan 07 14:11:31 GMT 2022 - 856 bytes - Click Count (0) -
tests/test_list_bytes_file_order_preserved_issue_14811.py
monkeypatch: pytest.MonkeyPatch, ) -> None: app = FastAPI() @app.post("/upload") async def upload(files: Annotated[list[bytes], File()]): # return something that makes order obvious return [b[0] for b in files] original_read = StarletteUploadFile.read async def patched_read(self: StarletteUploadFile, size: int = -1) -> bytes: # Make the FIRST file slower *deterministically*Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 10 12:14:38 GMT 2026 - 1.4K bytes - Click Count (0) -
docs/zh-hant/docs/tutorial/server-sent-events.md
/// tip 因為 Pydantic 會在 **Rust** 端進行序列化,如果你有宣告回傳型別,效能會比未宣告時高很多。 /// ### 非 async 的路徑操作函式 { #non-async-path-operation-functions } 你也可以使用一般的 `def` 函式(沒有 `async`),並同樣使用 `yield`。 FastAPI 會確保正確執行,不會阻塞事件迴圈。 由於此函式不是 async,正確的回傳型別是 `Iterable[Item]`: {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[28:31] hl[29] *} ### 無回傳型別 { #no-return-type }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/zh-hant/docs/tutorial/stream-json-lines.md
如果你要回傳的每個 JSON 項目型別都是 `Item`(一個 Pydantic 模型),而且該函式是 async,你可以將回傳型別宣告為 `AsyncIterable[Item]`: {* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[1:24] hl[9:11,22] *} 如果你宣告了回傳型別,FastAPI 會用它來進行資料的**驗證**、在 OpenAPI 中**文件化**、**過濾**,並使用 Pydantic 進行**序列化**。 /// tip 由於 Pydantic 會在 **Rust** 端進行序列化,宣告回傳型別可獲得比未宣告時高得多的**效能**。 /// ### 非 async 的*路徑操作函式* { #non-async-path-operation-functions }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:33:04 GMT 2026 - 4.2K bytes - Click Count (0)