Hi all, I have a requirement, click on different links on the page and download different files. For example, when you click BPM link, download BPM file, and when you click ACN link, download ACN file. What should I do within download_excel (), the code is as follows. Any help is very appreciated.
import os
import sys
sys.path.append("./apps/")
from flask import send_file
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from config import TEMPLATE_DIRECTORY
from app import app
layout = html.Div(
[
html.A("BPM_Template", href="/BPM/"),
html.A("ACN_Template", href="/ACN/"),
html.A("SAP_Template", href="/SAP/"),
]
)
@app.server.route("/TimeSheet/")
def download_excel(filename):
return send_file(filename_or_fp=os.path.join(TEMPLATE_DIRECTORY, filename),
mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
attachment_filename=filename,
as_attachment=True,
cache_timeout=0
)