mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
or param errors to raise invalid data exception. That will cause those responses to be handled in by errors.py, which will log the errors. Set most of schemas to strict mode so that marshmallow will raise exception rather than checking for errors in return tuple from load. Added handler to errors.py for marshmallow validation errors.
22 lines
491 B
Python
22 lines
491 B
Python
from flask import (
|
|
Blueprint,
|
|
jsonify,
|
|
request
|
|
)
|
|
|
|
from app.errors import register_errors
|
|
|
|
from app.schemas import event_schema
|
|
from app.dao.events_dao import dao_create_event
|
|
|
|
events = Blueprint('events', __name__, url_prefix='/events')
|
|
register_errors(events)
|
|
|
|
|
|
@events.route('', methods=['POST'])
|
|
def create_event():
|
|
data = request.get_json()
|
|
event = event_schema.load(data).data
|
|
dao_create_event(event)
|
|
return jsonify(data=event_schema.dump(event).data), 201
|