()
| 2537 | |
| 2538 | # Async version |
| 2539 | async def router_async(): |
| 2540 | if self._got_first_request["pages"]: |
| 2541 | return |
| 2542 | self._got_first_request["pages"] = True |
| 2543 | |
| 2544 | inputs = { |
| 2545 | "pathname_": Input(_ID_LOCATION, "pathname"), |
| 2546 | "search_": Input(_ID_LOCATION, "search"), |
| 2547 | } |
| 2548 | inputs.update(self.routing_callback_inputs) |
| 2549 | |
| 2550 | @self.callback( |
| 2551 | Output(_ID_CONTENT, "children"), |
| 2552 | Output(_ID_STORE, "data"), |
| 2553 | inputs=inputs, |
| 2554 | prevent_initial_call=True, |
| 2555 | hidden=True, |
| 2556 | ) |
| 2557 | async def update(pathname_, search_, **states): |
| 2558 | query_parameters = _parse_query_string(search_) |
| 2559 | page, path_variables = _path_to_page( |
| 2560 | self.strip_relative_path(pathname_) |
| 2561 | ) |
| 2562 | if page == {}: |
| 2563 | for module, page in _pages.PAGE_REGISTRY.items(): |
| 2564 | if module.split(".")[-1] == "not_found_404": |
| 2565 | layout = page["layout"] |
| 2566 | title = page["title"] |
| 2567 | break |
| 2568 | else: |
| 2569 | layout = html.H1("404 - Page not found") |
| 2570 | title = self.title |
| 2571 | else: |
| 2572 | layout = page.get("layout", "") |
| 2573 | title = page["title"] |
| 2574 | |
| 2575 | if callable(layout): |
| 2576 | layout = await execute_async_function( |
| 2577 | layout, |
| 2578 | **{**(path_variables or {}), **query_parameters, **states}, |
| 2579 | ) |
| 2580 | if callable(title): |
| 2581 | title = await execute_async_function( |
| 2582 | title, **{**(path_variables or {})} |
| 2583 | ) |
| 2584 | return layout, {"title": title} |
| 2585 | |
| 2586 | _validate.check_for_duplicate_pathnames(_pages.PAGE_REGISTRY) |
| 2587 | _validate.validate_registry(_pages.PAGE_REGISTRY) |
| 2588 | |
| 2589 | if not self.config.suppress_callback_exceptions: |
| 2590 | |
| 2591 | async def get_layouts(): |
| 2592 | return [ |
| 2593 | await execute_async_function(page["layout"]) |
| 2594 | if callable(page["layout"]) |
| 2595 | else page["layout"] |
| 2596 | for page in _pages.PAGE_REGISTRY.values() |
nothing calls this directly
no test coverage detected