@GET('^/api/v1/get_ratings')
    @authenticated
    def get_ratings(self, request):
        def parse_response(ratings):
            if ratings is not None:
                request.setHeader('content-type', "application/json")
                request.write(json.dumps(sanitize_html(ratings), indent=4))
                request.finish()
            else:
                request.write(json.dumps({}))
                request.finish()
        if "guid" in request.args:
            def get_node(node):
                if node is not None:
                    if "contract_id" in request.args and request.args["contract_id"][0] != "":
                        self.mserver.get_ratings(node, unhexlify(request.args["contract_id"][0]))\
                            .addCallback(parse_response)
                    else:
                        self.mserver.get_ratings(node).addCallback(parse_response)
                else:
                    request.write(json.dumps({}))
                    request.finish()
            self.kserver.resolve(unhexlify(request.args["guid"][0])).addCallback(get_node)
        else:
            ratings = []
            if "contract_id" in request.args and request.args["contract_id"][0] != "":
                for rating in self.db.ratings.get_listing_ratings(request.args["contract_id"][0]):
                    ratings.append(json.loads(rating[0]))
            else:
                for rating in self.db.ratings.get_all_ratings():
                    ratings.append(json.loads(rating[0]))
            request.setHeader('content-type', "application/json")
            request.write(json.dumps(sanitize_html(ratings), indent=4))
            request.finish()
        return server.NOT_DONE_YET
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/api/restapi.py/OpenBazaarAPI.get_ratings/original