예제 #1
0
    def url_add_common_param(self):
        self.url = self.url + '?traceID=' + get_trace_id(
        ) + '&callSystemID=' + str(CALL_SYSTEM_ID)

        if not is_none(self.base_prj.common_params):
            for key, value in self.base_prj.common_params.items():
                self.url = self.url + "&" + str(key) + "=" + str(value)
예제 #2
0
 def self_error(code, msg):
     data = json.dumps({
         'traceID': get_trace_id(),
         'code': code,
         'msg': msg
     })
     response = make_response(data, 200)
     return response
예제 #3
0
def return_data(data=None, code=200, msg=u'成功', login_data=None):
    data = {} if data is None else data
    data_json = json.dumps({
        'traceID': get_trace_id(),
        'code': code,
        'msg': msg,
        'data': data
    })
    resp = make_response(data_json, 200)
    response = allow_cross_domain(resp)  # 允许跨域
    create_auth_cookie(response, login_data)  # 制作cookie
    return response
예제 #4
0
def return_data(code=200, data=None, msg=u'成功', login_data=None):
    data = {} if data is None else data
    data_json = json.dumps({'traceID': get_trace_id(),
                            'code': code,
                            'msg': msg,
                            'data': data})
    response = make_response(data_json, 200)
    response.headers['Content-Type'] = 'application/json'
    if request.headers.get('Origin') in MOBILE_ORIGIN_URL:
        response.headers['Access-Control-Allow-Origin'] = request.headers.get('Origin')
    else:
        response.headers['Access-Control-Allow-Origin'] = 'https://i.mofanghr.com'
    response.headers['Access-Control-Allow-Methods'] = 'PUT,GET,POST,DELETE'
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    response.headers['Access-Control-Allow-Headers'] = "Referer,Accept,Origin,User-Agent"
    create_auth_cookie(response, login_data)

    return response