瀏覽代碼

add 404 error page

Falko Schindler 2 年之前
父節點
當前提交
8178e9e144
共有 1 個文件被更改,包括 5 次插入0 次删除
  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))