flask 实现下载文件功能

第一种方式:

            UPLOAD_FOLDER = './info/modules/passport/{}.csv'.format(file_name)   # 第一种方法
            ROOT_FOLDER = os.path.join(os.getcwd(), UPLOAD_FOLDER)  # 整合绝对路径

            response = make_response(send_file(ROOT_FOLDER,mimetype='text/csv',attachment_filename='Adjacency.csv'))
            return response

第二种:


            return send_file('modules/down_table/tables/{}.csv'.format(file_name), mimetype='text/csv',
                             attachment_filename='{}Table_showing_the_financial.csv'.format(file_name), as_attachment=True)

你可能感兴趣的:(flask 实现下载文件功能)