OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to redirect to URL for a multipage Dash app

  • Thread starter Thread starter Cristian Munteanu
  • Start date Start date
C

Cristian Munteanu

Guest
Hello I need to add a new endpoint to my Dash (Plotly) web that redirects to a URL. I want to do something like the following. My Dash app is multipage, and I want to add a new endpoint (path): /embedded-ms that performs a redirection to a URL. When accessing this endpoint Dash app should redirect to given URL.

I have the following code that works fine:

Code:
@ms_app.app.callback(Output("page-content", "children"), Input("url", "pathname"))     

def render_page_content(pathname):     

     authorized = True #TODO: Change this when better integration with DNN         

     if ((pathname == "/") or (pathname == "/login/callback")):             

         return heatmaps_page.page_content         

     elif pathname == "/page-gestion":             

         return gestion_page.page_content

And I want to add a new condition that performs the redirection:

Code:
elif pathname == "/embedded-ms":     

    return redirect("https://www.somewebsite.com/mob/bi-ms?iframe=true" )

This does not work, however, so I'm stuck. Thanks
<p>Hello I need to add a new endpoint to my <code>Dash</code> (Plotly) web that redirects to a URL. I want to do something like the following. My Dash app is multipage, and I want to add a new endpoint (path): <code>/embedded-ms</code> that performs a redirection to a URL. When accessing this endpoint Dash app should redirect to given URL.</p>
<p>I have the following code that works fine:</p>
<pre class="lang-py prettyprint-override"><code>@ms_app.app.callback(Output("page-content", "children"), Input("url", "pathname"))

def render_page_content(pathname):

authorized = True #TODO: Change this when better integration with DNN

if ((pathname == "/") or (pathname == "/login/callback")):

return heatmaps_page.page_content

elif pathname == "/page-gestion":

return gestion_page.page_content
</code></pre>
<p>And I want to add a new condition that performs the redirection:</p>
<pre class="lang-py prettyprint-override"><code>elif pathname == "/embedded-ms":

return redirect("https://www.somewebsite.com/mob/bi-ms?iframe=true" )
</code></pre>
<p>This does not work, however, so I'm stuck. Thanks</p>
 

Latest posts

M
Replies
0
Views
1
MOHAMED AMIIN ABDI AADAN
M
Top