I use dash a little different because I need to use OIDC with keycloak. On top I need to call another keycloak client/API to get an id from the user who wants to access my endpoint. With this id I want to generate the endpoints dynamically.
I have now the dash app assigned to the Flask server:
app = Flask(__name__)
oidc = OpenIDConnect(app)
dashboard = dash.Dash(server = app, name = 'Dashboard', url_base_pathname='/dashboardx/')
A function which redirects to the dashboard app:
def render_dashboard(id):
if id == 33:
report.layout = html.Div([
html.H1('some_id 33 layout')])
return redirect('/dashboardx/')
The Flask API:
@app.route('/redirect/', endpoint='route1')
@oidc.require_login
def route_rt():
.....some oidc stuff...
assigning some_id variable
if some_id is not None:
return render_dashboard(some_id)
This works, so far. The problems:
If I have 1000 dashboards for each user, do I have to declare them each repetitive? like dashboard1 = ...url_base_pathname='/dashboard1/')
, dashboard2 = ...url_base_pathname='/dashboard2/')
Or is there a more elegant way to define them dynamically?
like dashboard<some_id> = ...url_base_pathname='/dashboard<some_id>/')
is this possible? I couldn’t find a way yet