- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 89 for handlers (0.24 sec)
-
fastapi/exception_handlers.py
) async def request_validation_exception_handler( request: Request, exc: RequestValidationError ) -> JSONResponse: return JSONResponse( status_code=HTTP_422_UNPROCESSABLE_ENTITY, content={"detail": jsonable_encoder(exc.errors())}, ) async def websocket_request_validation_exception_handler( websocket: WebSocket, exc: WebSocketRequestValidationError ) -> None:
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sun Jun 11 19:08:14 GMT 2023 - 1.3K bytes - Viewed (0) -
tests/test_exception_handlers.py
app = FastAPI( exception_handlers={ HTTPException: http_exception_handler, RequestValidationError: request_validation_exception_handler, Exception: server_error_exception_handler, } ) client = TestClient(app) @app.get("/http-exception") def route_with_http_exception(): raise HTTPException(status_code=400) @app.get("/request-validation/{param}/")
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Thu Feb 17 12:40:12 GMT 2022 - 1.9K bytes - Viewed (0) -
docs/en/docs/tutorial/handling-errors.md
## Override the default exception handlers **FastAPI** has some default exception handlers. These handlers are in charge of returning the default JSON responses when you `raise` an `HTTPException` and when the request has invalid data. You can override these exception handlers with your own. ### Override request validation exceptions
Plain Text - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Fri Mar 22 01:42:11 GMT 2024 - 9.1K bytes - Viewed (0) -
docs/en/docs/advanced/events.md
{!../../../docs_src/events/tutorial001.py!} ``` In this case, the `startup` event handler function will initialize the items "database" (just a `dict`) with some values. You can add more than one event handler function. And your application won't start receiving requests until all the `startup` event handlers have completed. ### `shutdown` event
Plain Text - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Thu Apr 18 19:53:19 GMT 2024 - 7.8K bytes - Viewed (0) -
tests/test_starlette_exception.py
assert response.json() == {"detail": "Item not found"} def test_no_body_status_code_exception_handlers(): response = client.get("/http-no-body-statuscode-exception") assert response.status_code == 204 assert not response.content def test_no_body_status_code_with_detail_exception_handlers(): response = client.get("/http-no-body-statuscode-with-detail-exception") assert response.status_code == 204
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Fri Jun 30 18:25:16 GMT 2023 - 7.4K bytes - Viewed (0) -
docs/en/docs/tutorial/dependencies/dependencies-with-yield.md
This was changed in version 0.110.0 to fix unhandled memory consumption from forwarded exceptions without a handler (internal server errors), and to make it consistent with the behavior of regular Python code.
Plain Text - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sat Feb 24 23:06:37 GMT 2024 - 14.1K bytes - Viewed (0) -
docs_src/handling_errors/tutorial006.py
from fastapi import FastAPI, HTTPException from fastapi.exception_handlers import ( http_exception_handler, request_validation_exception_handler, ) from fastapi.exceptions import RequestValidationError from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI() @app.exception_handler(StarletteHTTPException) async def custom_http_exception_handler(request, exc): print(f"OMG! An HTTP error!: {repr(exc)}")
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sun Aug 09 11:10:33 GMT 2020 - 928 bytes - Viewed (0) -
tests/test_ws_router.py
def test_depend_err_handler(): """ Verify that it is possible to write custom WebSocket middleware to catch errors """ async def custom_handler(websocket: WebSocket, exc: CustomError) -> None: await websocket.close(1002, "foo") myapp = make_app(exception_handlers={CustomError: custom_handler}) client = TestClient(myapp)
Python - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sun Jun 11 19:08:14 GMT 2023 - 7.5K bytes - Viewed (0) -
docs/en/docs/advanced/testing-events.md
# Testing Events: startup - shutdown When you need your event handlers (`startup` and `shutdown`) to run in your tests, you can use the `TestClient` with a `with` statement: ```Python hl_lines="9-12 20-24" {!../../../docs_src/app_testing/tutorial003.py!}
Plain Text - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Sat Aug 29 14:02:58 GMT 2020 - 262 bytes - Viewed (0) -
docs/en/docs/how-to/async-sql-encode-databases.md
So, you will be able to see it all in the interactive API docs. ## Connect and disconnect * Create your `FastAPI` application. * Create event handlers to connect and disconnect from the database. ```Python hl_lines="42 45-47 50-52" {!../../../docs_src/async_sql_databases/tutorial001.py!} ``` ## Read notes Create the *path operation function* to read notes:
Plain Text - Registered: Sun Apr 28 07:19:10 GMT 2024 - Last Modified: Thu Apr 18 19:53:19 GMT 2024 - 5.3K bytes - Viewed (0)