Esempio n. 1
0
def messages_add():

    message_text = request.json.get('text')

    if message_text != '':
        new_message = Message(text=message_text)
        Message.append_message_to_user(new_message, g.user)

        return (jsonify(message=new_message.to_json(),
                        user=g.user.to_json()), 201)

    else:
        return (jsonify(error="Please enter a message into the text box"), 204)