def send_response(self, data=None, err_code=0, err_msg=''): if not data: data = {} data['return_code'] = 'SUCCESS' if err_code == 0 else 'FAIL' data['return_msg'] = err_msg self.write(dtools.dict2xml(data)) self.finish()
def encrypt_data(data, crypter, appid): encrypted = {'encrypt': crypter.encrypt(dtools.dict2xml(data), appid)} add_sign_wechat(encrypted, key='wechat_platform') return dtools.transfer( encrypted, renames=[ ('encrypt', 'Encrypt'), ('sign', 'MsgSignature'), ('timestamp', 'TimeStamp'), ('nonce', 'Nonce')])
def send_response(self, data=None, err_code=0, err_msg=''): if data: self.write(dtools.dict2xml(data)) self.finish()
def write_error(self, status_code, **kwargs): data = {'return_code': 'FAIL', 'return_msg': str(status_code)} self.write(dtools.dict2xml(data))