def create_talk(): data = json.loads(request.data) date = data.get('date') if date: date = datetime.datetime.strptime(date, '%B %d, %Y') data['date'] = date try: talk = Talk.create(**data) except ValueError as e: flash(e.message, 'danger') return json.dumps({'message': e.message}), 400, {'Content-Type': 'application/json'} return json.dumps(talk.to_dict()), 200, {'Content-Type': 'application/json'}
def create_talk(): data = json.loads(request.data) date = data.get('date') if date: date = datetime.datetime.strptime(date, '%B %d, %Y') data['date'] = date try: talk = Talk.create(**data) except ValueError as e: flash(e.message, 'danger') return json.dumps({'message': e.message}), 400, { 'Content-Type': 'application/json' } return json.dumps(talk.to_dict()), 200, { 'Content-Type': 'application/json' }