コンテンツにスキップ
per page, with , order by , clip by
Results of 1 - 4 of about 4 for task (0.003 sec.)
Response - Change Status Code 11298
Response - Change Status Code Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You probably read before that you can set a default Response Status Code . But in som ... status_code in that temporal response object. Python 3.8+ from fastapi import FastAPI , Response , status app = FastAPI () tasks = { "foo" : "Listen to the Bar Fighters" } @app . put ( "/get-or-create-task/ {task_id} " , status_code = 200 ) def get_o ... r_create_task ( task_id : str , response : Response ): if task_id not in tasks : tasks [ task_id ] = "This didn't exist before" response ... . status_code = status . HTTP_201_CREATED return tasks [ task_id ] And then you can return any object you need, as you normally would (a dict , a database model, etc). And if y ...
https://man.mtool.work/fastapi/0.115/advanced/response-change-status-code/
バックグラウンドタスク 10855
バックグラウンドタスク レスポンスを返した 後に 実行されるバックグラウンドタスクを定義できます。 これは、リクエスト後に処理を開始する必要があるが、クライアントがレスポンスを受け取る前に処理を終える必要のない操作に役立ちます。 これには、たとえ ... る処理を必要とするファイル受信時には、「受信済み」(HTTP 202) のレスポンスを返し、バックグラウンドで処理できます。 BackgroundTasks の使用 まず初めに、 BackgroundTasks をインポートし、 BackgroundTasks の型宣言と共に、 path operation 関数 のパラメーターを ... 定義します: Python 3.8+ from fastapi import BackgroundTasks , FastAPI app = FastAPI () def write_notification ( email : str , message = "" ): with open ( "log.txt" , mode = "w" ) as ... . write ( content ) @app . post ( "/send-notification/ {email} " ) async def send_notification ( email : str , background_tasks : BackgroundTasks ): background_tasks . add_task ( write_notification , email , message = "some notification" ) return { ...
https://man.mtool.work/fastapi/0.115/tutorial/background-tasks/
Async Tests 7415
Async Tests Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You have already seen how to test your FastAPI applications using the provided TestClient . Up to now, ... application in your tests, exactly as you would call them anywhere else in your code. Tip If you encounter a RuntimeError: Task attached to a different loop when integrating asynchronous function calls in your tests (e.g. when using MongoDB's MotorCl ...
https://man.mtool.work/fastapi/0.115/advanced/async-tests/
Release Notes 7360
Release Notes Latest Changes 0.115.11 Fixes ? Add docs examples and tests (support) for Annotated custom validations, like AfterValidator , revert #13440 . PR #13442 by @tiangolo . New docs: Query Parameters and String Validations - Custom ... R #13168 by @alejsdev . ✅ Simplify tests for bigger_applications. PR #13167 by @alejsdev . ✅ Simplify tests for background_tasks. PR #13166 by @alejsdev . ✅ Simplify tests for additional_status_codes. PR #13149 by @tiangolo . Docs ✏️ Update Strawberr ... en/docs/advanced/response-directly.md . PR #12803 by @handabaldeep . ? Update includes in docs/zh/docs/tutorial/background-tasks.md . PR #12798 by @zhaohan-dong . ? Update includes for docs/de/docs/tutorial/body-multiple-params.md . PR #12699 by @ali ... /tutorial/body-multiple-params.md . PR #12593 by @Tashanam-Shahbaz . ? Update includes in docs/pt/docs/tutorial/background-tasks.md . PR #12736 by @bhunao . ? Update includes for docs/en/docs/advanced/custom-response.md . PR #12797 by @handabaldeep . ...
https://man.mtool.work/fastapi/0.115/release-notes/
PREV 1 NEXT