- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 60 for media_type (0.06 seconds)
The search processing time has exceeded the limit. The displayed results may be partial.
-
docs/en/docs/reference/responses.md
- media_type - body - background - raw_headers - render - init_headers - headers - set_cookie - delete_cookie ::: fastapi.responses.PlainTextResponse options: members: - charset - status_code - media_type - bodyCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 22 16:34:59 GMT 2026 - 4.4K bytes - Click Count (0) -
tests/test_request_body_parameters_media_type.py
@app.post("/shops") async def create_shop( data: Shop = Body(media_type=media_type), included: list[Product] = Body(default=[], media_type=media_type), ): pass # pragma: no cover client = TestClient(app) def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text assert response.json() == snapshot( {
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 7.2K bytes - Click Count (0) -
docs_src/custom_response/tutorial009c_py310.py
from typing import Any import orjson from fastapi import FastAPI, Response app = FastAPI() class CustomORJSONResponse(Response): media_type = "application/json" def render(self, content: Any) -> bytes: assert orjson is not None, "orjson must be installed" return orjson.dumps(content, option=orjson.OPT_INDENT_2) @app.get("/", response_class=CustomORJSONResponse) async def main():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 451 bytes - Click Count (0) -
docs_src/custom_response/tutorial008_py310.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 360 bytes - Click Count (0) -
docs_src/additional_responses/tutorial002_py310.py
"description": "Return the JSON item or an image.", } }, ) async def read_item(item_id: str, img: bool | None = None): if img: return FileResponse("image.png", media_type="image/png") else:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 596 bytes - Click Count (0) -
tests/test_default_response_class_router.py
from fastapi import APIRouter, FastAPI from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse from fastapi.testclient import TestClient class OverrideResponse(JSONResponse): media_type = "application/x-override" app = FastAPI() router_a = APIRouter() router_a_a = APIRouter() router_a_b_override = APIRouter() # Overrides default class router_b_override = APIRouter() # Overrides default class
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 20:49:20 GMT 2020 - 5K bytes - Click Count (0) -
fastapi/sse.py
with protocols like MCP that stream SSE over `POST`. The actual encoding logic lives in the FastAPI routing layer. This class serves mainly as a marker and sets the correct `Content-Type`. """ media_type = "text/event-stream" def _check_id_no_null(v: str | None) -> str | None: if v is not None and "\0" in v: raise ValueError("SSE 'id' must not contain null characters") return vCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 6.2K bytes - Click Count (0) -
docs/en/docs/advanced/stream-data.md
For example, you can create a `PNGStreamingResponse` that sets the `Content-Type` header to `image/png` using the `media_type` attribute: {* ../../docs_src/stream_data/tutorial002_py310.py ln[6,19:20] hl[20] *} Then you can use this new class in `response_class=PNGStreamingResponse` in your *path operation function*:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 5.4K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/stream-data.md
在上述範例中,雖然串流了資料位元組,但回應沒有 `Content-Type` 標頭,因此用戶端不知道接收到的是哪種資料型別。 你可以建立 `StreamingResponse` 的自訂子類別,將 `Content-Type` 標頭設定為你要串流的資料型別。 例如,你可以建立 `PNGStreamingResponse`,透過 `media_type` 屬性把 `Content-Type` 設為 `image/png`: {* ../../docs_src/stream_data/tutorial002_py310.py ln[6,19:20] hl[20] *} 接著在路徑操作函式中用 `response_class=PNGStreamingResponse` 使用這個新類別:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:33:04 GMT 2026 - 4.9K bytes - Click Count (0) -
docs/zh/docs/advanced/stream-data.md
在上面的示例中,虽然按字节流式传输了数据,但响应没有 `Content-Type` 头,因此客户端不知道接收到的数据类型。 你可以创建 `StreamingResponse` 的自定义子类,将 `Content-Type` 头设置为你要流式传输的数据类型。 例如,你可以创建一个 `PNGStreamingResponse`,通过 `media_type` 属性把 `Content-Type` 头设置为 `image/png`: {* ../../docs_src/stream_data/tutorial002_py310.py ln[6,19:20] hl[20] *} 然后你可以在*路径操作函数*中通过 `response_class=PNGStreamingResponse` 使用这个新类:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:29:48 GMT 2026 - 5.2K bytes - Click Count (0)