Hi @AnnMarieW,
It’s great to see this support for multipage apps, very nice implementation with a flask-like API!
I am having trouble getting pages with path_template to work, with the following setup:
home.py
dash.register_page(__name__, path="/")
def layout(**kwargs):
base_page.py
dash.register_page(
__name__,
name="Pages",
path_template="/pages/<page_slug>",
title=title,
description=description,
path="/pages/child-eduction",
)
def layout(page_slug=None, **query_parmas):
print_registry()
page = Page.query.filter_by(slug=page_slug).first_or_404()
What seems to be happening is that any URL is resolving to the base_page route, even / and even /admin provided by Flask-Admin, which of course throws a 404 as page_slug s not populated, the page registry looks like this:
{'pages.home': {'module': 'pages.home',
'supplied_path': '/',
'path_template': None,
'path': '/',
'supplied_name': None,
'name': 'Home',
'supplied_title': None,
'title': 'Home',
'description': '',
'order': 0,
'supplied_order': None,
'supplied_layout': None,
'supplied_image': None,
'image': None,
'image_url': None,
'redirect_from': None,
'relative_path': '/',
'layout': <function layout at 0xffff5c1addc0>},
'pages.base_page': {'module': 'pages.base_page',
'supplied_path': '/pages/child-eduction',
'path_template': '/pages/<page_slug>',
'path': '/pages/child-eduction',
'supplied_name': 'Pages',
'name': 'Pages',
'supplied_title': <function title at 0xffff5ca0bee0>,
'title': <function title at 0xffff5ca0bee0>,
'description': <function description at 0xffff5c1a1940>,
'order': None,
'supplied_order': None,
'supplied_layout': None,
'supplied_image': None,
'image': None,
'image_url': None,
'redirect_from': None,
'relative_path': '/pages/child-eduction',
'layout': <function layout at 0xffff5c1a1a60>}}
Flask routes are the following:
Endpoint Methods Rule
----------------------------------------------------------------------- --------- -----------------------------------------------------------------------
/ GET /
/<path:path> GET /<path:path>
/_dash-component-suites/<string:package_name>/<path:fingerprinted_path> GET /_dash-component-suites/<string:package_name>/<path:fingerprinted_path>
/_dash-dependencies GET /_dash-dependencies
/_dash-layout GET /_dash-layout
/_dash-update-component POST /_dash-update-component
/_favicon.ico GET /_favicon.ico
/_reload-hash GET /_reload-hash
_dash_assets.static GET /assets/<path:filename>
admin.index GET /admin/
admin.static GET /admin/static/<path:filename>
fileadmin.action_view POST /admin/fileadmin/action/
fileadmin.delete POST /admin/fileadmin/delete/
fileadmin.download GET /admin/fileadmin/download/<path:path>
fileadmin.edit GET, POST /admin/fileadmin/edit/
fileadmin.index GET /admin/fileadmin/old_b/<path:path>
fileadmin.index GET /admin/fileadmin/old_index
fileadmin.index_view GET /admin/fileadmin/b/<path:path>
fileadmin.index_view GET /admin/fileadmin/
fileadmin.mkdir GET, POST /admin/fileadmin/mkdir/<path:path>
fileadmin.mkdir GET, POST /admin/fileadmin/mkdir/
fileadmin.rename GET, POST /admin/fileadmin/rename/
fileadmin.upload GET, POST /admin/fileadmin/upload/<path:path>
fileadmin.upload GET, POST /admin/fileadmin/upload/
page.action_view POST /admin/page/action/
page.ajax_lookup GET /admin/page/ajax/lookup/
page.ajax_update POST /admin/page/ajax/update/
page.create_view GET, POST /admin/page/new/
page.delete_view POST /admin/page/delete/
page.details_view GET /admin/page/details/
page.edit_view GET, POST /admin/page/edit/
page.export GET /admin/page/export/<export_type>/
page.index_view GET /admin/page/
static GET /static/<path:filename>
And my requirements are:
orjson
dash_treeview_antd
dash==2.6.1
dash-bootstrap-components==1.1.0
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-renderer==1.9.0
dash-table==5.0.0
flask-cors==3.0.10
Flask-Admin==1.6.0
flask-sqlalchemy==2.5.1
Flask-Migrate==3.1.0
slugify
Any pointers for me on what could be wrong here?
Thanks,
James