def put(self, message_id): title = request.form.get('title') body = request.form.get('body') message = MessageModel.find_message_by_id(message_id) if message is None: message = MessageModel(title, body, author_id) else: if title: message.title = title if body: message.body = body message.save_to_db() return {'message': message.to_json()}
def post(self): message = MessageModel(request.form.get('title'), request.form.get('body'), request.form.get('author_id')) message.save_to_db() return {'message': message.to_json()}, 201