- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 56 for exception (0.19 sec)
-
fastapi/exception_handlers.py
async def http_exception_handler(request: Request, exc: HTTPException) -> Response: headers = getattr(exc, "headers", None) if not is_body_allowed_for_status_code(exc.status_code): return Response(status_code=exc.status_code, headers=headers) return JSONResponse( {"detail": exc.detail}, status_code=exc.status_code, headers=headers ) async def request_validation_exception_handler(
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Sun Jun 11 19:08:14 GMT 2023 - 1.3K bytes - Viewed (0) -
tests/test_starlette_exception.py
) return {"item": items[item_id]} @app.get("/http-no-body-statuscode-exception") async def no_body_status_code_exception(): raise HTTPException(status_code=204) @app.get("/http-no-body-statuscode-with-detail-exception") async def no_body_status_code_with_detail_exception(): raise HTTPException(status_code=204, detail="I should just disappear!") @app.get("/starlette-items/{item_id}")
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_src/security/tutorial004.py
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Mar 26 16:56:53 GMT 2024 - 4K bytes - Viewed (0) -
docs_src/security/tutorial004_an.py
username: str = payload.get("sub") if username is None: raise credentials_exception token_data = TokenData(username=username) except JWTError: raise credentials_exception user = get_user(fake_users_db, username=token_data.username) if user is None: raise credentials_exception return user async def get_current_active_user(
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Mar 26 16:56:53 GMT 2024 - 4.1K bytes - Viewed (0) -
docs_src/security/tutorial004_an_py310.py
username: str = payload.get("sub") if username is None: raise credentials_exception token_data = TokenData(username=username) except JWTError: raise credentials_exception user = get_user(fake_users_db, username=token_data.username) if user is None: raise credentials_exception return user async def get_current_active_user(
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Mar 26 16:56:53 GMT 2024 - 4.1K bytes - Viewed (0) -
docs_src/security/tutorial005_an.py
if username is None: raise credentials_exception token_scopes = payload.get("scopes", []) token_data = TokenData(scopes=token_scopes, username=username) except (JWTError, ValidationError): raise credentials_exception user = get_user(fake_users_db, username=token_data.username) if user is None: raise credentials_exception for scope in security_scopes.scopes:
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Mar 26 16:56:53 GMT 2024 - 5.3K bytes - Viewed (0) -
tests/test_ws_router.py
def test_depend_validation(): """ Verify that a validation in a dependency invokes the correct exception handler """ caught = [] @websocket_middleware async def catcher(websocket, call_next): try: return await call_next() except Exception as e: # pragma: no cover caught.append(e) raise
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_src/dependencies/tutorial008c_an.py
from fastapi import Depends, FastAPI, HTTPException from typing_extensions import Annotated app = FastAPI() class InternalError(Exception): pass def get_username(): try: yield "Rick" except InternalError: print("Oops, we didn't raise again, Britney 😱") @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id == "portal-gun":
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Sat Feb 24 23:06:37 GMT 2024 - 710 bytes - Viewed (0) -
docs_src/dependencies/tutorial008b_an_py39.py
app = FastAPI() data = { "plumbus": {"description": "Freshly pickled plumbus", "owner": "Morty"}, "portal-gun": {"description": "Gun to create portals", "owner": "Rick"}, } class OwnerError(Exception): pass def get_username(): try: yield "Rick" except OwnerError as e: raise HTTPException(status_code=400, detail=f"Owner error: {e}") @app.get("/items/{item_id}")
Python - Registered: Sun May 05 07:19:11 GMT 2024 - Last Modified: Tue Dec 26 20:37:34 GMT 2023 - 775 bytes - Viewed (0) -
ci/official/containers/linux_arm64/devel.usertools/squash_testlogs.py
runfiles_matcher = re.compile(r"(/.*\.runfiles/)") for f in files.strip().splitlines(): # Just ignore any failures, they're probably not important try: r = JUnitXml.fromfile(f) except Exception as e: # pylint: disable=broad-except print("Ignoring this XML parse failure in {}: ".format(f), str(e)) source_file = re.search( r"/(bazel_pip|tensorflow)/.*", f.decode("utf-8") ).group(0)
Python - Registered: Tue May 07 12:40:20 GMT 2024 - Last Modified: Mon Sep 18 19:00:37 GMT 2023 - 4.8K bytes - Viewed (0)