@app.route('/method', methods=['POST'])
def api_entry():
    file_data = dataObject.createFileData()
return send_file(file_data, as_attachment=True, mimetype='text/plain',
    attachment_filename='somefile.txt')
How to clean up temporary file used with send_file?