As stated by @hussam for a Multi-Page Dash app, you have to adjust it a bit.
Based on the simple Dash Multi app example, it would look like this:
from dash import Dash, dcc, html, callback, Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
# represents the browser address bar and doesn't render anything
dcc.Location(id='url', refresh=False),
dcc.Link('Navigate to "/"', href='/'),
html.Br(),
dcc.Link('Navigate to "/page-2"', href='/page-2'),
# content will be rendered in this element
html.Div(id='page-content')
])
@callback(
Output('page-content', 'children'),
[Input('url', 'pathname')])
def display_page(relative_pathname):
return html.Div([
html.H3(f'You are on page {relative_pathname}'),
html.A(html.Button('Refresh Page'),href=relative_pathname),
])
if __name__ == '__main__':
app.run_server(debug=True)
With the input method for url:
[Input('url', 'pathname')])
You can get the relative url path, so everything after your main domain.
And with this input, you can setup a a refresh button for this page:
html.A(
html.Button('Refresh Page'),
href=relative_pathname
see example:
