コード例 #1
0
def follow_user_topics():
    """
  This function is used to update the database to include following a user's
    topics.
  :return: Display information about the action.
  """

    log("Request - {}".format(
        inspect.getframeinfo(inspect.currentframe()).function))

    try:
        # Get the info from the json file sent with the request
        data = request.get_json()

        try:
            userId = data['userId']
            followingId = data['followingId']
            topicsSelected = data['topicsSelected']

        except KeyError:
            return invalid_json_format_string

        db.updateFollow(userId, followingId, topics=topicsSelected)

    except Exception as e:
        log(str(e))

    return """
  Followed a user's topics!
  userId: {}
  followingId: {}
  topicsSelected: {}
  """.format(userId, followingId, topicsSelected)
コード例 #2
0
def follow_new_user():
    """
  This function is used to follow a new user.
  :return: Display information about the update.
  """

    log("Request - {}".format(
        inspect.getframeinfo(inspect.currentframe()).function))

    try:
        # Get the info from the json file sent with the request
        data = request.get_json()

        try:
            userId = data['userId']
            followingId = data['followingId']
            topics = data['topics'] = "G"
        except KeyError:
            return invalid_json_format_string

        db.updateFollow(userId, followingId)
        log("Followed new user")
    except Exception as e:
        log(str(e))
        log(traceback.format_exception(Exception, e, None))
        return "Error"

    return """
Followed a new user!
  userId: {}
  followingId: {}
""".format(userId, followingId)