@mod.route('/upload', methods=['POST', 'GET'])
def upload():
if request.method == 'POST':
f = request.files['file']
basepath = r"D:\exe_file"
upload_path = os.path.join(basepath, 'testexe', secure_filename(f.filename))
f.save(upload_path)
@mod.route("/download", methods=["GET"])
def download():
exe_record_id = request.args.get("exe_record_id", 1)
pre_path = r"D:\exe_file_record\%s" % exe_record_id
if not os.path.exists(pre_path + '\\' + str(exe_record_id) + ".zip"):
return jsonify({"msg": "Please wait while the report is being generated.", "ret": -1})
response = make_response(
send_from_directory(pre_path, str(exe_record_id) + ".zip", as_attachment=True))
return response
def zip_file(f1, f2, report_id):
f = zipfile.ZipFile(f1 + "\\" + str(report_id) + ".zip", 'w', zipfile.ZIP_DEFLATED)
dirpath = f2
for path, dirnames, filenames in os.walk(dirpath):
fpath = path.replace(dirpath, '')
for filename in filenames:
f.write(os.path.join(path, filename), os.path.join(fpath, filename))
f.close()
command = "D:\\channel_trunk\\bin64\\your_exe.exe %s %s %s %s" % (base_client, source_file_list,
product_dir, parm_shd)
print(command)
f = os.popen(command)
data = f.readlines()
f.close()
print(data)