def get(self): try: user = self.current_user data = yield self.data.get_favoritetagname(user) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, e))
def post(self): try: user = self.current_user json = self.get_json() data = yield self.data.insert_favoritetag(user, **json) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, e))
def get(self, video_id): try: if not video_id: raise ValueError(errors.VIDEO_NOT_FOUND) data = yield self.data.get_videocomment(video_id) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self, uid): if not uid: self.finish(Respon(Nonerespon)) else: try: data = yield self.data.get_user(uid) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, e))
def get(self): try: user = self.current_user if not user: raise RuntimeError(errors.LOGIN_COOKIES_INVALID) data = yield self.data.get_user(user.uid) self.finish((Respon(Baserespon, data=data))) except Exception as e: self.finish(Respon(Badrespon, e))
def get(self, *args, **kwargs): user = self.current_user if not user: self.finish(Respon(Badrespon, errors.LOGIN_COOKIES_INVALID)) else: data = { 'islogin': True, 'account': user.account, 'nickname': user.nickname, 'id': user.uid } self.finish(Respon(Baserespon, data=data))
def post(self): try: json = self.get_json() if not json: raise RuntimeError(errors.JSON_SHOULD_BE_NOT_NONE) message = json.get('message', '') reply = '' if message == '你好': reply = '你好呀~' elif message == '你来过这里吗?你拍的视频好有意思': pass self.finish(Respon(Baserespon, data=reply)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self): try: longitude = self.get_argument('longitude', None) latitude = self.get_argument('latitude', None) level = self.get_argument('level', 8) page = int(self.get_argument('page', 1)) - 1 # 数据第0页开始 if longitude and latitude and level: data = yield self.data.get_videoswithneighbour( longitude, latitude, level, page) self.finish(Respon(Baserespon, data=data)) else: self.finish(Respon(Nonerespon)) except Exception as e: self.finish(Respon(Badrespon, e))
def get(self, video_id): try: if not video_id: page = int(self.get_argument('page', 1)) - 1 #数据第0页开始 uid = self.get_argument('uid', None) if not uid: data = yield self.data.get_videos(page) else: data = yield self.data.get_videos_uid(uid, page) else: data = yield self.data.get_video(video_id) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def delete(self, user_id): try: user = self.current_user yield self.data.defocus_user(user_id, user.uid) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def put(self, commentid): try: if not commentid: raise ValueError(errors.COMMENT_NOT_FOUND) yield self.data.update_like_videocomment(commentid) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self, *args, **kwargs): try: type = self.get_argument('type', 'send') page = int(self.get_argument('page', 1)) - 1 # 数据第0页开始 user = self.current_user if not user: raise RuntimeError(errors.LOGIN_COOKIES_INVALID) if type == 'send': data = yield self.data.get_send_message(user.uid, page) elif type == 'recive': data = yield self.data.get_recive_message(user.uid, page) elif type == 'unreadnum': data = yield self.data.unread_messagenum(user.uid) else: data = None self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self): try: # user = self.current_user # if user: # vids = yield self.recommend_video('-5104583026337327941') # else: # vids = yield self.recommend_video('-5104583026337327941') vids = ['6584690495409097991', '6584398245387046147', '6570100343449849092',\ '6584573083351256327', '6580138391453568264', '6502363396086697229',\ '6569537911270673677', '6585385921045073159', '6584251747315748109',\ '6584626231122070798'] if vids: data = yield self.data.get_videoswithvids(vids) else: data = yield self.data.get_videos(page=0) self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self, user_id): try: type = self.get_argument('type', 'fan') page = int(self.get_argument('page', 1)) - 1 #数据第0页开始 user = self.current_user if not user: raise RuntimeError(errors.LOGIN_COOKIES_INVALID) if type == 'fan': data = yield self.data.get_fanuser(user.uid, page) elif type == 'master': data = yield self.data.get_masteruser(user.uid, page) elif type == 'isfollow': data = yield self.data.isfollow(user_id, user.uid) else: data = None self.finish(Respon(Baserespon, data=data)) except Exception as e: self.finish(Respon(Badrespon, message=e))
def post(self, *args, **kwargs): try: json = self.get_json() uid, nickname, account = yield self.data.create_user(**json) self.set_secure_cookie('uid', str(uid)) self.set_secure_cookie('nickname', nickname) self.set_secure_cookie('account', account) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, e))
def post(self, *args, **kwargs): try: user = self.current_user json = self.get_json() if not user: raise RuntimeError(errors.LOGIN_COOKIES_INVALID) yield self.data.insert_message(user.uid, **json) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def post(self, video_id): try: user = self.current_user json = self.get_json() if user is None: raise RuntimeError(errors.LOGIN_COOKIES_INVALID) if not video_id: raise ValueError(errors.VIDEO_NOT_FOUND) yield self.data.insert_videocomment(video_id, user.uid, **json) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def get(self): data = yield self.data.get_videotag() self.finish(Respon(Baserespon, data=data))
def delete(self, messageid): try: yield self.data.delete_message(messageid) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def put(self, video_id): try: yield self.data.like_video(video_id) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))
def put(self, messageid): try: yield self.data.read_message(messageid) self.finish(Baserespon) except Exception as e: self.finish(Respon(Badrespon, message=e))