Simple example of multi-page Dash app in Julia

I couldn’t find any examples of how to build multi-page Dash apps using Julia, so I ported the python example from the docs to julia (using callbacks):

using Dash

app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])

app.layout = html_div() do
    html_h1("Hello Dash"),
    dcc_location(id="url", refresh=false),
    dcc_link("Navigate to /", href="/"),
    html_br(),
    dcc_link("Navigate to page-2", href="page-2"),
    html_br(),
    html_div(id="page-content")
end


function display_page(pathname)
  return html_div() do
    html_h3("You are on page $(pathname)")
  end
end


callback!(app, Output("page-content", "children"), Input("url", "pathname")) do input_value
  display_page(input_value)
end


run_server(app, "0.0.0.0", debug=true)
1 Like