def get(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() arr = obj.getDefaultFlag(openId) return jsonify({"flags": arr})
def post(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() data = request.get_json(force=True) if not obj.getInfo(openId): abort(404, message="请先填写信息") check = obj.checkTimeCapsule(openId) msg = None if check['check_voice'] or check['check_text']: time = obj.getTime(openId) else: time = data['time'] if data['type'] == "voice": if check['check_voice']: abort(409, message="已经填写过语音信件了。") else: try: msg = data['file_id'] except: abort(400, message="参数错误。") try: r = requests.get( "https://hemc.100steps.net/2017/wechat/Home/Public/getMedia?media_id=%s" % msg, timeout=20) t = json.loads(r.text) except: abort(404, message="file_id错误") return False if t["status"] == 0: try: f = open( "media/%s.amr" % hashlib.md5( msg.encode(encoding='UTF-8')).hexdigest(), "wb") f.write(base64.b64decode(t["data"])) f.close() except Exception as e: abort(404, message=str(e)) else: abort(404, message="录音文件不存在。") obj.sendTimeCapsule(openId, data['type'], msg, time) else: if check['check_text']: abort(409, message="已经填写过文字信件了。") else: try: msg = data['message'] except: abort(400, message="参数错误。") if data['send_offline']: obj.sendTimeCapsule(openId, data['type'], msg, time, data['send_offline'], data['address']) else: obj.sendTimeCapsule(openId, data['type'], msg, time, data['send_offline']) return jsonify({"errcode": 0, "errmsg": ""})
def get(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() if not obj.getInfo(openId): abort(404, message="请先填写信息") return jsonify({"check_flag": obj.checkFlag(openId)})
def get(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() if not obj.getInfo(openId): abort(404, message="请先填写信息") check = obj.checkTimeCapsule(openId) return jsonify({ "check_text": check['check_text'], "check_voice": check['check_voice'] })
def get(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() flag = obj.getFlag(openId) name = obj.getInfo(openId)['name'] if flag: _flag = pickle.loads(flag) print(_flag[0]) return jsonify({"name": name, "flag": _flag}) else: abort(404, message="请先填写flag。")
def post(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() if not obj.getInfo(openId): abort(404, message="请先填写信息") if obj.checkFlag(openId): abort(409, message="已经填写过flag") else: data = request.get_json(force=True) _flag = pickle.dumps(data['flag']) obj.sendFlag(openId, _flag) return jsonify({"errcode": 0})
def post(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() info = obj.getInfo(openId) if info: abort(409, message="已经填写过信息了。") else: data = request.get_json(force=True) if checkTel(data['tel']): obj.updateInfo(openId, data['name'], data['tel']) return jsonify({"errcode": 0, "errmsg": ""}) else: abort(400, message="手机号无效。")
def post(self): checkTime() openId = checkLogin() # checkSubscribe(openId) data = request.get_json(force=True) if checkTel(data['sender_tel']) and checkTel(data['receiver_tel']): obj = database() if obj.sendOfflineCapsule(data['sender_name'], data['sender_tel'], data['receiver_name'], data['receiver_tel'], data['receiver_addr'], data['capsule_tag'], data['time']): return jsonify({"errcode": 0}) else: abort(400, message="手机号错误。")
def get(self): checkTime() openId = checkLogin() # checkSubscribe(openId) obj = database() info = obj.getInfo(openId) if info: check = obj.checkTimeCapsule(openId) return jsonify({ "record": True, "name": info['name'], "tel": info['tel'], "check_flag": obj.checkFlag(openId), "check_text": check['check_text'], "check_voice": check['check_voice'] }) else: return jsonify({"record": False})