mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 06:08:13 +02:00
renamed the json validation more appropriately
This commit is contained in:
@ -9,7 +9,7 @@ router = Blueprint('answers', __name__, url_prefix='/answers')
|
|||||||
ALLOWED_EXT = {'json'}
|
ALLOWED_EXT = {'json'}
|
||||||
|
|
||||||
|
|
||||||
def validate_json_format(data: str) -> dict[str, str]:
|
def validate_json_format_for_comment_gen(data: str) -> dict[str, str]:
|
||||||
try:
|
try:
|
||||||
obj = json.loads(data)
|
obj = json.loads(data)
|
||||||
if not isinstance(obj, dict):
|
if not isinstance(obj, dict):
|
||||||
@ -32,7 +32,7 @@ def submit_comments():
|
|||||||
return jsonify({'error': 'Only JSON files are allowed'}), 400
|
return jsonify({'error': 'Only JSON files are allowed'}), 400
|
||||||
data = file.read().decode()
|
data = file.read().decode()
|
||||||
try:
|
try:
|
||||||
validated = validate_json_format(data)
|
validated = validate_json_format_for_comment_gen(data)
|
||||||
except InvalidJsonFormatError as e:
|
except InvalidJsonFormatError as e:
|
||||||
return jsonify({'error': 'Invalid JSON format', 'message': str(e)}), 400
|
return jsonify({'error': 'Invalid JSON format', 'message': str(e)}), 400
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user