NSS-Day-Cohort-58 / rare-python-server-striking-dragons

rare-python-server-striking-dragons created by GitHub Classroom
0 stars 0 forks source link

Request Handler: `do_PUT()` (1) #40

Open MckenzieLR opened 2 years ago

MckenzieLR commented 2 years ago
def do_PUT(self):
    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)

# Delete a single animal from the list
    if resource == "orders":
        update_post(id, post_body)

# Encode the new animal and send in response
    self.wfile.write("".encode())