I have a JSON file in the flask app that i send via either send_from_directory() or via send_file() i have tried both. This triggers on button click but the browser opens the file directly instead of getting a download dialog box. I researched a bit and found out Firefox and Chrome have an inbuilt option to do this, however i want it to always download instead of opening no matter the setting in the browser.
Flask Code
def download_file():
filename = "requiredFields.json"
return send_from_directory(app.config['MAIN_FOLDER'],filename,as_attachment=True)
HTML That calls it
<a href="{{url_for('download_file',filename = file)}}"class="btn btn-primary" type="button">Download</a>