def handle_request(self): request = self.request.path.split('/') request = request[len(request)-1] if hasattr(self, request): result = getattr(self, request)() response = simplejson.dumps(result) self.response.out.write(response) else: self.error(404)
def post(self): if self.request.get('pwd').lower() == 'd1am0ndwedd1ng': blobs = [] blob_query = blobstore.BlobInfo.all() for blob in blob_query: tmp = {} tmp['filename'] = str(blob.filename) tmp['size'] = str(round((blob.size / (1024.0 * 1024.0)), 1)) + "MB" tmp['key'] = str(blob.key()) blobs.append(tmp) self.template_values['blobs'] = simplejson.dumps(blobs) self.forward('serve.html')
def post(self): args = simplejson.loads(self.request.body) func, args = args[0], args[1:] if func[0] == '_': self.error(403) # access denied else: func = getattr(self, func, None) if not func: self.error(404) # file not found else: self.response.out.write(simplejson.dumps(func(*args)))
def get(self): action = self.request.get('action') if not action: self.response.out.write(self.create()) elif action[0] == '_': self.error(403) else: func = getattr(self, action, None) if not func: self.error(404) else: args = () while True: val = self.request.get('arg%d' % len(args)) if val: args += (simplejson.loads(val),) else: break self.response.out.write(simplejson.dumps(func(*args)))