def _dispatch_request(self, request, response): directory = self.configuration['upload_directory'] if request.method == 'GET': return elif request.method != 'POST': raise MethodNotAllowed() mapping = {} for name, uploaded_file in request.files.iteritems(): filename = mapping[name] = '%s_%s' % ( uniqid(), secure_filename(uploaded_file.filename)) uploaded_file.save(os.path.join(directory, filename)) response.mimetype = 'text/html' response.data = Json.serialize(mapping)
def _prepare_response(self, response, content): response.mimetype = 'application/json' response.data = Json.serialize(content)