I set up an example multipage app, using
backend ---> __init__.py ---> applcation.py pages ---> home_page.py ---> not_found_404.py ---> page2.py run.py
from .application import app
from dash import Dash, html, dcc import dash pages_folder = '../pages' app = Dash(__name__, use_pages=True, pages_folder=pages_folder) app.layout = html.Div([ dash.page_container ])
import dash from dash import html, dcc dash.register_page(__name__, path='/') layout = html.Div('Home page')
import dash from dash import html, dcc, callback, Input, Output dash.register_page(__name__) layout = html.Div('Page2!!')
from dash import html import dash dash.register_page(__name__) layout = html.H1("This is a custom 404 page that does not work")
from backend import app if __name__ == '__main__': app.run_server(debug=True)
When I move the dash app in such a way, that I do not need to set
path_pages, it does work as expected.
I was thinking, that the relative path in
path_pages could be responsible for that behavior.
Weirdly, when setting
pages_folder=os.getcwd() + '/pages', I get an error message with
A folder called … does not exist.
While when trying to set
assets_folder=os.getcwd + '/custom_assets', it works.
assets_folder work differently. The former can only handle relative paths while the latter can also work with absolute ones? This seems odd to me
This seems to be connected to Bug - cannot register not_found_404 with dash.register_page() - #6 by jinnyzor
Should I open a bug report in git?