Can I trigger a Dash function via a Flask app.route or URL?

Hey guys

This is probably crazy, and I probably don’t know enough about web frameworks like Flask and Django. But here goes.

Goal
I want to trigger a user-defined function in my Dash app from the browser URL or an underlying Flask app as an @app.route.

Why?
I want to display a particular view within my dash app via a hard URL, effectively like a simple API.

Example
myappdomain.com/query_string/query_year

I know in flask you can grab variables straight from the path, such as:

@app.route('/<string:query>/<int:year>')
def blah(query,year):
    #... Logic goes here
    return <call child dash app function somehow>

So I guess I’m wondering if it’s possible to somehow trigger a specific dash function/callback from the return ‘view’ of a flask route? Or if indeed this cam be done more simply from within the dash app itself?? (I dont actually need a custom flask app)

The idea would be you could redirect to display a specific state of your dash app DIRECTLY via the URL string, like an API, just as if the user had navigated there themselves.

Is this possible in any way?

Hey @dan_baker have you tried dcc.Location()?

1 Like

Ann you mistake me for a competent Dash programmer…

Thank you so much. I think that will do the trick!

Dan

There is no mistake about that! You do nice work :slight_smile:

1 Like