I tried to build a minimal example of a Dash app that illustrates the problem of dynamically generating a file that can then be downloaded via a download button.
If
Solution here:
import uuid
import dash
from dash.dependencies import Input, Output, State
import flask
from flask.helpers import send_file
import dash_core_components as dcc
import dash_html_components as html
stylesheets = [
"https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css", # Bulma
]
server = flask.Flask('app')
# create app
app = dash.Dash(
__name__,
external_stylesheets=stylesheets,
server=server # <-- do not forget this line
)
# (...) your code here
@server.route("/downloadable/")
def download_file (path = None):
return send_file("downloadable/" + path, as_attachment=True)