Explorar o código

add 404 error page

Falko Schindler %!s(int64=2) %!d(string=hai) anos
pai
achega
8178e9e144
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      nicegui/nicegui.py

+ 5 - 0
nicegui/nicegui.py

@@ -60,6 +60,11 @@ def shutdown() -> None:
     globals.state = globals.State.STOPPED
 
 
+@app.exception_handler(404)
+async def exception_handler(_: Request, exc: Exception):
+    return error_client.build_response(404, str(exc))
+
+
 @app.exception_handler(Exception)
 async def exception_handler(_: Request, exc: Exception):
     return error_client.build_response(500, str(exc))