Esempio n. 1
0
 def wrapper(*args, **kwargs):
     output = dict(code=200, message='success', data={})
     try:
         ret = func(*args, **kwargs)
         data = ret.get_json()
         output['data'] = data
     except KeyError as e:
         output['code'] = '400'
         output['message'] = "缺少参数"
         output['info'] = "缺少参数{}".format(str(e))
         print(traceback.format_exc())
         return jsonify(output)
     except FlaskException as e:
         output['code'] = e.code
         output['message'] = e.message
         output['info'] = str(e)
         print(traceback.format_exc())
         return jsonify(output)
     except Exception as e:
         output['code'] = 500
         output['message'] = '网络繁忙'
         output['info'] = traceback.format_exc()
         print(traceback.format_exc())
         logger.error(traceback.format_exc())
         logger.error("Unexpect Error: {}".format(str(e)))
     return jsonify(output)
Esempio n. 2
0
def health():
    print(2333)
    logger.error("23333")
    return "200"
Esempio n. 3
0
def internal_server_error(e):
    logger.error(format_exc())
    ret = Response(status=500)
    ret.message = str(sys.exc_info()[1])
    ret.error_data = format_exc()
    return ret
Esempio n. 4
0
def api_str():
    print(2333)
    logger.error("2333")
    raise Exception("参数错误")
    return '666'
Esempio n. 5
0
def api_jsonify():
    print(2333)
    logger.error("2333")
    return jsonify([])
Esempio n. 6
0
def api_dict():
    print(2333)
    logger.error("2333")
    return {}