def do_DELETE(self): # Set a 204 response code self._set_headers(204) # Parse the URL (resource, id) = self.parse_url(self.path) # Delete a single animal from the list if resource == "animals": delete_animal(id) self.wfile.write("".encode()) if resource == "locations": delete_location(id) self.wfile.write("".encode()) if resource == "employees": delete_employee(id) self.wfile.write("".encode()) if resource == "customers": delete_customer(id) self.wfile.write("".encode())
def do_DELETE(self): self._set_headers(204) resource, id = self.parse_url(self.path) if resource == "animals": delete_animal(id) elif resource == "customers": delete_customer(id) elif resource == "employees": delete_employee(id) elif resource == "locations": delete_location(id) self.wfile.write("".encode())
def do_DELETE(self): # Parse the URL (resource, id) = self.parse_url(self.path) # Set a 204 response code # Delete a single animal from the list if resource == "animals": success = delete_animal(id) #True or False if success: self._set_headers(204) else: self._set_headers(404) if resource == "locations": success = delete_location(id) if resource == "employees": success = delete_employee(id) if resource == "customers": success = delete_customer(id) # Encode the new animal and send in response self.wfile.write("".encode())
def do_DELETE(self): # Set a 204 response code (Processed but no information to send back) self._set_headers(204) (resource, id) = self.parse_url(self.path) if resource == "animals": delete_animal(id) if resource == "locations": delete_location(id) if resource == "employees": delete_employee(id) if resource == "customers": delete_customer(id) self.wfile.write("".encode())
def do_DELETE(self): # Set a 204 response code # A 204 response code in HTTP means, "I, the server, successfully processed your request, but I have no information to send back to you." self._set_headers(204) # Parse the URL (resource, id) = self.parse_url(self.path) # Delete a single animal from the list if resource == "animals": delete_animal(id) # Delete a single customer from the list if resource == "customers": delete_customer(id) # Delete a single employee from the list if resource == "employees": delete_employee(id) # Delete a single location from the list if resource == "locations": delete_location(id)
def do_DELETE(self): # Set a 204 response code self._set_headers(204) # Parse the URL (resource, id) = self.parse_url(self.path) chosenResourceToDelete = None # Delete a single animal from the list if resource == "animals": chosenResourceToDelete = delete_animal(id) elif resource == "locations": chosenResourceToDelete = delete_location(id) elif resource == "employees": chosenResourceToDelete = delete_employee(id) elif resource == "customers": chosenResourceToDelete = delete_customer(id) # Encode the new animal and send in response self.wfile.write(f"{chosenResourceToDelete}".encode())