def handler()

in functions/APIs/getRecommendationsByBook.py [0:0]


def handler(event, context):
    
    graph = Graph()
    
    g = graph.traversal().withRemote(DriverRemoteConnection(myNeptuneEndpoint,"g"))
    
    toReturn = g.V(event["pathParameters"]["bookId"]).project("friendsPurchased","purchased") \
        .by(in_("purchased").dedup().where(id().is_(P.neq(event["pathParameters"]["bookId"]))).id().fold()).by(in_("purchased").count()).toList()
    
    response = {
        "statusCode": 200,
        "headers": {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Credentials": True
        },
        "body": json.dumps(toReturn)
    }
    
    print(response)
    return response