def post(self): user = validate_user(username=request.params['username'], pwd_md5=request.params['pwd']) if not user: return render_response(StatusDef.USER_NOT_FOUND) token = login_user(user) return render_response(data=user.to_json(), cookies={'token': token})
def get(): locations = [] loc = ip_to_location('59.42.120.121' or request.ip) if loc: locations.append(loc) target_id, ad_id = target_ads(locations, request.params['content']) ad = get_ad(ad_id) data = ad.to_json() return render_response(data={'target_id': target_id, 'data': data})
def get(self): quit = [False] filter_type = request.params['type'] arg = request.params.get(filter_type) data = [] filter_gen = filter_content(request.user_id, filter_type, arg, quit) for item in filter_gen: data.append(item) return render_response(data=data)
def handle_error(error): """统一处理自定义错误响应码""" return render_response(error.code, help=error.help)
def delete(self, ad_id): remove_ad(ad_id) return render_response()
def post(self, ad_id): data = record_click(**request.params) return render_response(data=data)
def get(self, ad_id): ad = get_ad(ad_id) data = ad.to_json() return render_response(data=data)
def post(self): data = add_ad(**request.params) return render_response(data=data)
def delete(self): ret = unfollow_user(request.user_id, request.params['other_uid']) if not ret: return render_response(StatusDef.USER_UNLIKED) else: return render_response()
def delete(self): token = request.get_token() logout_user(token) return render_response()
def get(self): user = get_user(request.user_id) return render_response(data=user.to_json())
def delete(self, status_id): ret = delete_status(request.user_id, status_id) if not ret: return render_response(StatusDef.STATUS_DELETE_FAIL) else: return render_response()
def post(self): ret = post_status(request.user_id, request.params['content']) if not ret: return render_response(StatusDef.STATUS_CREATE_FAIL) else: return render_response()
def get(self): statuses = get_status_contents( request.user_id, **request.params ) return render_response(data=statuses)