Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Redirect to homepage if the file is not found #92

Open
drkane opened this issue Feb 26, 2019 · 1 comment
Open

Redirect to homepage if the file is not found #92

drkane opened this issue Feb 26, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@drkane
Copy link
Contributor

drkane commented Feb 26, 2019

Relies on this pull request going through. Suggested addition to index.py:

from dash import DashResponse
from flask import redirect
from tsg_insights.data.cache import get_metadata_from_cache

@app.callback(Output('for-redirect', 'data'),
              [Input('output-data-id', 'data')],
              [State('url', 'pathname')])
def update_file_id(fileid, existing_url):
    f = get_metadata_from_cache(fileid)
    if not f:
        return redirect('/?fetch={}'.format(fileid), 302) 
    return None

(relies on dcc.Store(id='for-redirect') being added to app.layout

@r-chris
Copy link

r-chris commented May 17, 2019

I just stumbled across your issue here. The PR plotly/dash#401 didn't make it, but plotly/dash#623 was merged in its place. You can now modify the dash.callback_response object, although I haven't figured out how to get it to perform a redirect, yet.

@drkane drkane added the enhancement New feature or request label Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants