def _dispatch_request(self, request, response): service = self.service if request.method == 'GET': return self._prepare_response(response, {'id': service['id'], 'pid': self.runtime.pid}) data = Json.unserialize(request.data) if data['status'] == 'restarting': self._prepare_response(response, {'status': 'restarting'}) self.runtime.reload() elif data['status'] == 'starting': content = self.runtime._execute_service_startup(self.service['id'], data.get('stage')) self._prepare_response(response, content)
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 _dispatch_request(self, request, response): service = self.service if request.method == 'GET': return self._prepare_response(response, { 'id': service['id'], 'pid': self.runtime.pid }) data = Json.unserialize(request.data) if data['status'] == 'restarting': self._prepare_response(response, {'status': 'restarting'}) self.runtime.reload() elif data['status'] == 'starting': content = self.runtime._execute_service_startup( self.service['id'], data.get('stage')) self._prepare_response(response, content)
def _prepare_response(self, response, content): response.mimetype = 'application/json' response.data = Json.serialize(content)