Example #1
0
 def auth():
     token = None
     try:
         auth_header = request.headers.get('Authorization')
         print(auth_header)
         token = auth_header.split(" ")[0]
         if Users.decode_token(token):
             return func(token)
     except Exception as ex:
         return ex
Example #2
0
def rate_movies(token):
    try:
        user_id, movie_data = Users.decode_token(token), request.get_json()
        for movie in movie_data:
            movieAttributeList = []
            for attribute, value in movie.items:
                movieAttributeList.append(value)
            newRatings = Movies(user_id, movieAttributeList[0],
                                movieAttributeList[1])
            newRatings.add_rating()
            # initialiseMovieModel()
        return jsonify({'movies': movie_data, 'message': 'Ratings added'}), 201
    except Exception as ex:
        return jsonify({'Error': ex, 'message': 'Add Ratings failed'}), 400