Skip to content

Commit

Permalink
Added page not found handling, still needs a bit more love though to …
Browse files Browse the repository at this point in the history
…show the real 404 page.
  • Loading branch information
Alyxion committed Apr 5, 2024
1 parent ab67606 commit fac0356
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nicegui/single_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import urllib.parse
from typing import Callable, Dict, Union, Optional, Tuple

from fastapi import HTTPException
from fastapi.routing import APIRoute

from nicegui import background_tasks, helpers, ui, core, Client, app
Expand Down Expand Up @@ -225,6 +226,8 @@ def open(self, target: Union[Callable, str, Tuple[str, bool]]) -> None:
else:
server_side = True
entry, route_args, query_args = self.get_router_entry(target)
if entry is None:
entry = ui.label(f"Page not found: {target}").classes("text-red-500") # Could be beautified
title = entry.title if entry.title is not None else core.app.config.title
ui.run_javascript(f'document.title = "{title}"')
if server_side:
Expand Down

0 comments on commit fac0356

Please sign in to comment.