def soardownload(): arg = request.values.to_dict() if 'data' not in arg or 'key' not in arg: return json.dumps({"result": 'data or key is None', "status": False}) try: args = json.loads(decrypt(arg['data'], arg['key'])) except Exception as e: return json.dumps({"result": str(e), "status": False}) if DEBUG: print(args) check = soar_args_check(args) if check: return check result = soar_result(args) map = json.loads(result) resp = make_response(map['result']) # 设置时间戳 nowTime = time.time() timeArray = time.localtime(nowTime) otherStyleTime = time.strftime("%Y%m%d%H%M%S", timeArray) # 后缀名 suffixMap = {'html': 'html', 'json': 'json', 'markdown': 'md'} suffix = 'html' # 设置 http 头 resp.headers['Content-Type'] = 'application/force-download' if 'report-type' in args and args['report-type'] in suffixMap: suffix = suffixMap[args['report-type']] resp.headers['Content-Disposition'] = 'filename=soar_%s.%s' % ( otherStyleTime, suffix) return resp
def soar(): args = request.values.to_dict() if DEBUG: print(args) check = soar_args_check(args) if check: return check result = soar_result(args) return result
def soar(): arg = request.json if 'data' not in arg or 'key' not in arg: return json.dumps({"result": 'data or key is None', "status": False}) try: args = json.loads(decrypt(arg['data'], arg['key'])) except Exception as e: return json.dumps({"result": str(e), "status": False}) if DEBUG: print(args) check = soar_args_check(args) if check: return check result = soar_result(args) return result
def soardownload(): args = request.values.to_dict() if DEBUG: print(args) check = soar_args_check(args) if check: return check result = soar_result(args) map = json.loads(result) resp = make_response(map['result']) nowTime = time.time() timeArray = time.localtime(nowTime) otherStyleTime = time.strftime("%Y%m%d%H%M%S", timeArray) resp.headers['Content-Type'] = 'application/force-download' resp.headers[ 'Content-Disposition'] = 'filename=soar_%s.html' % otherStyleTime return resp
def soardownload(): args = request.values.to_dict() if DEBUG: print (args) check = soar_args_check(args) if check: return check result = soar_result(args) map = json.loads(result) resp = make_response(map['result']) nowTime = time.time() timeArray = time.localtime(nowTime) otherStyleTime = time.strftime("%Y%m%d%H%M%S", timeArray) resp.headers['Content-Type'] = 'application/force-download' suffixMap = {'html' : 'html', 'json' : 'json', 'markdown' : 'md'} suffix = 'html' if 'report-type' in args and args['report-type'] in suffixMap : suffix = suffixMap[args['report-type']] resp.headers['Content-Disposition'] = 'filename=soar_%s.%s' % (otherStyleTime, suffix) return resp