Example #1
0
    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})
Example #2
0
    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})
Example #3
0
    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)
Example #4
0
 def handle_error(error):
     """统一处理自定义错误响应码"""
     return render_response(error.code, help=error.help)
Example #5
0
 def delete(self, ad_id):
     remove_ad(ad_id)
     return render_response()
Example #6
0
 def post(self, ad_id):
     data = record_click(**request.params)
     return render_response(data=data)
Example #7
0
 def get(self, ad_id):
     ad = get_ad(ad_id)
     data = ad.to_json()
     return render_response(data=data)
Example #8
0
 def post(self):
     data = add_ad(**request.params)
     return render_response(data=data)
Example #9
0
 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()
Example #10
0
    def delete(self):
        token = request.get_token()
        logout_user(token)

        return render_response()
Example #11
0
 def get(self):
     user = get_user(request.user_id)
     return render_response(data=user.to_json())
Example #12
0
 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()
Example #13
0
 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()
Example #14
0
 def get(self):
     statuses = get_status_contents(
         request.user_id,
         **request.params
     )
     return render_response(data=statuses)