New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Official download component #216
Comments
We could possible draw inspiration from here: https://github.com/axetroy/react-download |
I've also used Flask functionality for this. To serve static files: import os
import dash
from flask import send_from_directory
app = dash.Dash()
STATIC_PATH = os.path.join(app.server.root_path, 'static')
# define layout...
# add links with, for example: href='/static/test.csv'
@app.server.route('/static/<filename>')
def serve_static(filename):
return send_from_directory(STATIC_PATH, filename) Serving dynamic files is also possible with Flask: https://matthewmoisen.com/blog/how-to-download-a-csv-file-in-flask/, which looks similar to URI links, but supports older web browsers |
+1 for the feature. |
Hi. Is it is implemented already now? @chriddyp |
Dash has a default static files folder "assets" so any files there can be linked to as "assets/FILENAME.X" so you can use that for e.g. CSS files and downloadable static files. For a downloadable static file just add a link on the page. Dynamic file downloads still requires an URI link creation. |
Thannk you @amarvin. |
Another workaround: |
I made an unofficial
Is there any guide to how the syntax should be in Dash? Any comments/ideas? To enable easy download of common objects such as files or dataframes, i had to add a few utility functions (written in Python). Is there anywhere that these could be put in Dash? Or should they stay in a separate utility library? Here is an example for a dataframe,
|
Great! When you're ready, make a PR to
The above syntax looks good to me, but we would discuss details in the PR review.
Assuming they're fairly general-purpose (which df-to-excel certainly would be!) these can go in |
There are a few ways that you can download content with Dash:
The former apparently doesn't work in IE11 (plotly/dash-recipes#11) and the latter is a little bit out of the Dash framework (URL parameters instead of just inputs).
So, maybe there is a case for a proper download component.
The text was updated successfully, but these errors were encountered: