Multipage App with Sidebar navigation

Hello,

I’m trying to make a multipage app, with easy sidebar navigation. The documentation relates the content of the pages with the following function:

def render_page_content(pathname):
    if pathname == "/":
        return html.P("This is the content of the home page!")
    elif pathname == "/page-1":
        return html.P("This is the content of page 1. Yay!")
    elif pathname == "/page-2":
        return html.P("Oh cool, this is page 2!")
    # If the user tries to reach a different page, return a 404 message
    return dbc.Jumbotron(
        [
            html.H1("404: Not found", className="text-danger"),
            html.Hr(),
            html.P(f"The pathname {pathname} was not recognised..."),
        ]
    )

Now, when attempting to add user input to these pages, I get errors on the callback:

File “”, line 82
@app.callback(dash.dependencies.Output(‘page-1-content’, ‘children’),
^
SyntaxError: invalid syntax

I’ve been stuck trying to get this to work. All multipage stuff I’ve seen just uses links, which I dislike. For my use, a simple sidebar navigation is all I need. Is there a way around having to deal with having to create .py files for each page, and relating them through an app.py and index.py, like the multipage documentation shows?

Hi @cmues

You might need to store the value of the user input to be rendered again and not be lost when the user navigates away from the page.