Beispiel #1
0
 def decorated_function(*args, **kwargs):
     resp = make_response(f(*args, **kwargs))
     req_h = request.headers
     h = resp.headers
     for header, value in headers.items():
         h[header] = value
     h['Access-Control-Allow-Origin'] = req_h.get('Origin', '*')
     h['Access-Control-Allow-Credentials'] = 'true'
     accept_header = req_h.get('Access-Control-Request-Headers')
     if accept_header:
         h['Access-Control-Allow-Headers'] = accept_header
     return resp
Beispiel #2
0
 def decorated_function(*args, **kwargs):
     resp = make_response(func(*args, **kwargs))
     data = resp.data
     try:
         res_d = simplejson.loads(data)
         user_info = res_d.get('data')
         save_dict = {}
         if user_info:
             uid = user_info.get('uid')
             sid = str(uuid4())
             resp.set_cookie('sessionid', sid)
             remote_ip = request.remote_addr
             save_dict = {
                 'sid': sid,
                 'uid': uid,
                 'remote_ip': remote_ip}
             save_sesson(save_dict, db='usermanage', col='sessions')
     except Exception as e:
         _LOGGER.error('responed data error %s' % e)
     return resp
Beispiel #3
0
def _json_response(status, data, msg=None):
    d = {'status': status, 'data': data, 'msg': msg}
    response = make_response(ArmoryJson.encode(d))
    response.headers['Content-Type'] = 'application/json; charset=utf-8'
    return response