コード例 #1
0
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
コード例 #2
0
ファイル: soar-web.py プロジェクト: woihzh/soar-web
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
コード例 #3
0
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
コード例 #4
0
ファイル: soar-web.py プロジェクト: woihzh/soar-web
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
コード例 #5
0
ファイル: soar-web.py プロジェクト: lyl61521/soar-web
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