def post(self, channel_id): self.response.headers["Content-Type"] = "application/json" try: rating = self.request.POST["rating"] user_id = self.request.POST["user"] channel = Channels() channel.rate_channel(channel_id, rating, user_id) except Exception: logging.exception("Failed to rate channel %s" % channel_id) out = {"success": 0} self.response.write(json.dumps(out)) else: logging.info("Channel rated successfully") out = {"success": 1} self.response.write(json.dumps(out))