Results of 1 - 3 of about 3 for PlainTextResponse (0.001 sec.)
- エラーハンドリング 11459
- エラーハンドリング APIを使用しているクライアントにエラーを通知する必要がある状況はたくさんあります。 このクライアントは、フロントエンドを持つブラウザ、誰かのコード、IoTデバイスなどが考えられます。 クライアントに以下のようなことを伝える必要が
...fastapi import FastAPI , HTTPException from fastapi.exceptions import RequestValidationError from fastapi.responses import PlainTextResponse from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI () @app . exception_handler ( Starl...etteHTTPException ) async def http_exception_handler ( request , exc ): return PlainTextResponse ( str ( exc . detail ), status_code = exc . status_code ) @app . exception_handler ( RequestValidationError ) async def va...lidation_exception_handler ( request , exc ): return PlainTextResponse ( str ( exc ), status_code = 400 ) @app . get ( "/items/ {item_id} " ) async def read_item ( item_id : int ): if item_id =... - https://man.mtool.work/fastapi/0.115/tutorial/handling-errors/
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. 9505
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. There are several custom response classes you can use to create an instance and return them directly from your path operations . Read more about it in the FastAPI docs for Cust
...tly from fastapi.responses : from fastapi.responses import ( FileResponse , HTMLResponse , JSONResponse , ORJSONResponse , PlainTextResponse , RedirectResponse , Response , StreamingResponse , UJSONResponse , ) FastAPI Responses There are a couple of custom FastA...ype - body - background - raw_headers - render - init_headers - headers - set_cookie - delete_cookie ::: fastapi.responses.PlainTextResponse options: members: - charset - status_code - media_type - body - background - raw_headers - render - init_headers - headers... - https://man.mtool.work/fastapi/0.115/reference/responses/
- カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス 6920
- カスタムレスポンス - HTML、ストリーム、ファイル、その他のレスポンス デフォルトでは、 FastAPI は JSONResponse を使ってレスポンスを返します。 レスポンスを直接返す で見たように、 Response を直接返すことでこの挙動をオーバーライドできます。 しか
...a , media_type = "application/xml" ) HTMLResponse 上で読んだように、テキストやバイトを受け取り、HTMLレスポンスを返します。 PlainTextResponse テキストやバイトを受け取り、プレーンテキストのレスポンスを返します。 Python 3.8+ from fastapi import FastAPI from fastapi....responses import PlainTextResponse app = FastAPI () @app . get ( "/" , response_class = PlainTextResponse ) async def main (): return "Hello World" JSONRespo... - https://man.mtool.work/fastapi/0.115/advanced/custom-response/
PREV
1
NEXT