解决此问题的最佳方法是使用
send_file()flask中已经预定义的辅助函数:
@app.route("/api/downloadlogfile/<path>")def DownloadLogFile (path = None): if path is None: self.Error(400) try: return send_file(path, as_attachment=True) except Exception as e: self.log.exception(e) self.Error(400)


