I have the following chalice app:
# encoding: utf-8
from chalice import Chalice
from models import ContentItem
app = Chalice(app_name='moderations')
app.debug = True
@app.route("/item/{item_id}", methods=['GET'])
def view_item(item_id):
instance = ContentItem.get(ContentItem.id == item_id)
return model_to_dict(instance)
@app.route("/item/{item_id}", methods=['POST'])
def save_item(item_id):
request = app.current_request
data = request.json_body
instance = ContentItem.get(ContentItem.id == item_id)
instance.content = data
instance.save()
return
def model_to_dict(instance):
data = {'content': instance.content, 'id': instance.id}
return data
And I am running chalice local
When to go to GET http://localhost:8000/item/1234
, I get the record fine
But then if I go to POST http://localhost:8000/item/1234
, nothing happens, just sits there waiting ...
If I post first, which will work fine, then get the detail page, which results the same waiting game.
What have I done wrong?