# -*- coding: utf-8 -*-
from flask import Flask, render_template, send_file, send_from_directory,json, jsonify,make_response
app = Flask(__name__) #实例化flask app
#file_name是客户端传来的需要下载的文件名
@app.route('/get_file/<file_name>', methods=['GET'])
def get_file(file_name):
directory = config.APP_PATH
try:
response = make_response(
send_from_directory(directory, file_name, as_attachment=True))
return response
except Exception as e:
return jsonify({"code": "异常", "message": "{}".format(e)})
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0', port=80)
01-06
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-23
2007
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-05