INNER CODE UNIT · Python

unauthorized_exception_handler

AutomationPanda/bulldoggy-reminders-app · app/main.py:42

async def unauthorized_exception_handler(request: Request, exc: UnauthorizedPageException):
  return RedirectResponse('/login?unauthorized=True', status_code=302)


@app.exception_handler(404)
async def page_not_found_exception_handler(request: Request, exc: HTTPException):
  if request.url.path.startswith('/api/'):
    return JSONResponse({'detail': exc.detail}, status_code=exc.status_code)
  else:
    return RedirectResponse('/not-found')


# --------------------------------------------------------------------------------
# OpenAPI Customization
# --------------------------------------------------------------------------------

def custom_openapi():
  if app.openapi_schema:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…