Hi, in my webapp, I generate a pdf file with dynamic name by a function. Then I want the app to download it on the client. I tried passing the name to ajax->success, then create a link attribute. It generates "Not found" error.
def pdf_file_generator():
# ... file building instructions
pdf.output(f"/home/gionata15/templates/docs/{filename}")
return filename
JS approach
def download():
filename = pdf_file_generator()
return jsonify(f"/home/gionata15/templates/docs/{filename}")
attempt to download from app.py
def download():
filename = pdf_file_generator()
return send_file(f"/home/gionata15/templates/docs/{filename}", as_attachment=True)
I tried with return send_file and return send_from_directory but nothing happens.
Any solution?
Thanks
GM