1 回答

TA貢獻1786條經(jīng)驗 獲得超11個贊
正在調(diào)用該文件,download因為這是您設(shè)置的路徑。
@app.route('/download', methods=['GET'])
def download():
如果您沒有能力控制用戶的請求,您應該能夠通過使用重定向來定義一個虛假的文件名,否則只需使用定義的新路由進行下載。
嘗試這樣的事情?
...
from flask import redirect
...
@app.route('/download', methods=['GET'])
def download_redirect():
redirect('/download/test.xlsx')
@app.route('/download/<filename>', methods=['GET'])
def download(filename):
run_id = request.args.get('run_id')
fp = BucketHelper().get_report_fp(run_id)
send_file(fp,
as_attachment=True,
mimetype='application/vnd.ms-excel',
attachment_filename="test.xlsx")
添加回答
舉報