Python Flask – How to download a file with send_from_directory AND display text output in browser

Solution
@app.route('/downloadPage', methods=['GET'])
def download_page():
    return render_template("download_page.html")

@app.route('/downloadFile')
def download_file():
    return send_from_directory(output_directory, "myfile.txt", as_attachment=True)


def download_file():
    return send_file('static/downloads/filename.csv',
                     mimetype='text/csv',
                     as_attachment=True)
@app.route('/downloadFile')
def download_file():
    result = download_file()
    return result