flask中下载服务器上特定路径的文件

使用flask下载服务器上某个路径下的文件

path:文件路径以及需要下载的文件,直接写入参数有安全隐患,实际应用中需要判断权限之类的

from flask import send_file, make_response    
def down_file(path):
        response = make_response(flask.send_file(path))
        response.headers["Content-Disposition"] = "attachment; filename={};".format(file_name)
        return response