Hello! I was wondering if it was possible to access all current users’ session (or local) storage from a callback. I want to share large datasets between Dash and a Flask send_file similar to this example, but I am using an API to get data based on inputs instead of filtering an existing data set:
@app.callback(Output('my-link', 'href'), [Input('my-dropdown', 'value')])
def update_link(value):
return '/dash/urlToDownload?value={}'.format(value)
@app.server.route('/dash/urlToDownload')
def download_csv():
value = flask.request.args.get('value')
# create a dynamic csv or file here using `StringIO`
# (instead of writing to the file system)
strIO = StringIO.StringIO()
strIO.write('You have selected {}'.format(value))
strIO.seek(0)
return send_file(strIO,
mimetype='text/csv',
attachment_filename='downloadFile.csv',
as_attachment=True)
I would like to have a dictionary of all user’s current inputs (using a hash as an ID) and resulting data in a global variable to cut down on the export processing time (hitting the API and re-processing the data), but need to be aware of ram usage and purge the global variable of any abandoned IDs no longer in any session dcc.Store.