backend/api.py
def on_put(self, req, resp, article_uuid):
        """Update an article with url params using PUT"""

        # .decode() seems mandantory when running this in python3
        # See: http://stackoverflow.com/questions/6862770/python-3-let-json-object-accept-bytes-or-let-urlopen-output-strings
        req_body = json.loads(req.stream.read().decode('utf-8'))
        title = req_body['title']
        subtitle = req_body['subtitle']
        body = req_body['body']

        if title: blog.update_article(article_id=article_uuid, title=title)
        if subtitle: blog.update_article(article_id=article_uuid, subtitle=subtitle)
        if body: blog.update_article(article_id=article_uuid, body=body)

        resp.body = json.dumps(blog.fetch_article(article_id=article_uuid))
        resp.status = falcon.HTTP_200
Update an article with url params using PUT
Update an article with url params using PUT
Update an article with url params using PUT
def on_put(self, req, resp, article_uuid):
        req_body = json.loads(req.stream.read().decode('utf-8'))
        title = req_body['title']
        subtitle = req_body['subtitle']
        body = req_body['body']
        if title: blog.update_article(article_id=article_uuid, title=title)
        if subtitle: blog.update_article(article_id=article_uuid, subtitle=subtitle)
        if body: blog.update_article(article_id=article_uuid, body=body)
        resp.body = json.dumps(blog.fetch_article(article_id=article_uuid))
        resp.status = falcon.HTTP_200
def on_put ( self , req , resp , article_uuid ) : req_body = json . loads ( req . stream . read ( ) . decode ( 'utf-8' ) ) title = req_body [ 'title' ] subtitle = req_body [ 'subtitle' ] body = req_body [ 'body' ] if title : blog . update_article ( article_id = article_uuid , title = title ) if subtitle : blog . update_article ( article_id = article_uuid , subtitle = subtitle ) if body : blog . update_article ( article_id = article_uuid , body = body ) resp . body = json . dumps ( blog . fetch_article ( article_id = article_uuid ) ) resp . status = falcon . HTTP_200
Update an article with url params using PUT
Update an article with url params using PUT
"""Update an article with url params using PUT""" # .decode() seems mandantory when running this in python3 # See: http://stackoverflow.com/questions/6862770/python-3-let-json-object-accept-bytes-or-let-urlopen-output-strings
self
req
resp
article_uuid