def do_PUT(self): content_len = int(self.headers.get('content-length', 0)) post_body = self.rfile.read(content_len) post_body = json.loads(post_body) # Parse the URL (resource, id) = self.parse_url(self.path) success = False # Delete a single animal from the list if resource == "animals": update_animal(id, post_body) if resource == "customers": update_customer(id, post_body) if resource == "employees": update_employee(id, post_body) if resource == "locations": update_location(id, post_body) if success: self._set_headers(204) else: self._set_headers(404) # Encode the new animal and send in response self.wfile.write("".encode())
def do_PUT(self): content_len = int(self.headers.get('content-length', 0)) post_body = self.rfile.read(content_len) post_body = json.loads(post_body) # Parse the URL (resource, id) = self.parse_url(self.path) success = False if resource == "animals": success = update_animal(id, post_body) if resource == "customers": update_customer(id, post_body) if resource == "employees": update_employee(id, post_body) if resource == "locations": update_location(id, post_body) # rest of the elif's if success: self._set_headers(204) else: self._set_headers(404) self.wfile.write("".encode())
def do_PUT(self): self._set_headers(204) content_len = int(self.headers.get('content-length', 0)) post_body = self.rfile.read(content_len) # turns into post body when json loads post_body = json.loads(post_body) # Parse the URL (resource, id) = self.parse_url(self.path) # checks for resourse, passes id and post body if resource == "animals": update_animal(id, post_body) if resource == "customers": update_customer(id, post_body) if resource == "employees": update_employee(id, post_body) if resource == "locations": update_location(id, post_body) # Encode the new animal and send in response self.wfile.write("".encode())
def do_PUT(self): # You should be able to explain which HTTP method is used by the client to request that a resource's state should change. self._set_headers(204) content_len = int(self.headers.get('content-length', 0)) post_body = self.rfile.read(content_len) post_body = json.loads(post_body) # Parse the URL (resource, id) = self.parse_url(self.path) success = False if resource == "animals": success = update_animal(id, post_body) # Encode the new animal and send in response # self.wfile.write("".encode()) if resource == "customers": success = update_customer(id, post_body) # Encode the new customer and send in response # self.wfile.write("".encode()) if resource == "employees": success = update_employee(id, post_body) # Encode the new employee and send in response # self.wfile.write("".encode()) if resource == "locations": success = update_location(id, post_body) # Encode the new location and send in response if success: self._set_headers(204) else: self._set_headers(404) self.wfile.write("".encode())
def do_PUT(self): content_len = int(self.headers.get('content-length', 0)) post_body = self.rfile.read(content_len) post_body = json.loads(post_body) # Parse the URL (resource, id) = self.parse_url(self.path) print(resource) success = False # update single animal from list if resource == "animals": success = update_animal(id, post_body) elif resource == "customers": success = update_customer(id, post_body) elif resource == "employees": success = update_employee(id, post_body) elif resource == "locations": success = update_location(id, post_body) self.wfile.write("".encode())
def add_title(message): update_location(message.chat.id, 'title', message.text) bot.send_message(message.chat.id, text='Take a photo of the place') states.update_state(message, states.ADD_PHOTO)