@app.before_request
def require_json():
 if (request.method in {'GET', 'HEAD', 'DELETE'}):
  return
 if (request.mimetype != 'application/json'):
  abort(400, NO_HEADER)
 json_data = request.get_json(silent=True)
 if (json_data is None):
  abort(400, INVALID_JSON)

@ app . before_request def require_json ( ) : if ( request . method in { 'GET' , 'HEAD' , 'DELETE' } ) : return if ( request . mimetype != 'application/json' ) : abort ( 400 , NO_HEADER ) json_data = request . get_json ( silent = True ) if ( json_data is None ) : abort ( 400 , INVALID_JSON )
helper to let users know that they should submit the content-type header URL :return: abort() if an error occured .