demo.py 841 B

123456789101112131415161718
  1. from fastapi import Request, Response
  2. from nicegui import Client, app, ui
  3. @app.exception_handler(404)
  4. async def exception_handler_404(request: Request, exception: Exception) -> Response:
  5. with Client(ui.page('')) as client:
  6. with ui.column().style('width: 100%; padding: 5rem 0; align-items: center; gap: 0'):
  7. ui.label('Sorry').style('font-size: 3.75rem; line-height: 1; padding: 1.25rem 0')
  8. ui.label('Something went wrong.').style('font-size: 1.25rem; line-height: 1.75rem; padding: 1.25rem 0')
  9. ui.label('Please contact the server administrator at change@this.com for additional support.').style(
  10. 'font-size: 1.125rem; line-height: 1.75rem; color: rgb(107 114 128)')
  11. return client.build_response(request, 404)
  12. ui.link('Go to nonexisting page', '/nonexisting')
  13. ui.run()