コード例 #1
0
    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)

        if resource == "entries":
            update_entry(id, post_body)

        # Encode the new entry and send in response
        self.wfile.write("".encode())
コード例 #2
0
    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 url
        (resource, id) = self.parse_url(self.path)

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

        if resource == "moods":
            update_mood(id, post_body)
コード例 #3
0
    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)

        success = False
        # Parse the URL
        (resource, id) = self.parse_url(self.path)

        # Delete a single entrie from the list
        if resource == "entries":
            update_entry(id, post_body)
        if resource == "moods":
            update_mood(id, post_body)

        if success:
            self._set_headers(204)
        else:
            self._set_headers(404)

        # Encode the new entrie and send in response
        self.wfile.write("".encode())
コード例 #4
0
    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)

        (resource, id) = self.parse_url(self.path)

        success = False

        if resource == "entries":
            success = update_entry(id, post_body)

        if success:
            self._set_headers(204)
        else:
            self._set_headers(404)
        self.wfile.write("".encode())
コード例 #5
0
    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 == "entries":
            success = update_entry(id, post_body)
            # Encode the new entry and send in response
            # self.wfile.write("".encode())

        if success:
            self._set_headers(204)
        else:
            self._set_headers(404)

        self.wfile.write("".encode())