Skip to content

Commit aad7395

Browse files
committed
Added type checking
1 parent 82dfb1a commit aad7395

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

app.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from flask import Flask, jsonify, request
55
from models import Experience, Education, Skill
66
from gpt_connection import get_improvement
7-
from spell_check import spell_check_json
7+
from spell_check import spell_check
88
app = Flask(__name__)
99

1010
data = {
@@ -51,8 +51,8 @@ def experience():
5151

5252
if request.method == 'POST':
5353
json_data = request.json
54-
if json_data['spell_check']:
55-
json_data = spell_check_json(json_data)
54+
if json_data.get('spell_check') and isinstance(json_data.get('description'), str):
55+
json_data['description'] = spell_check(json_data['description'])
5656

5757
return jsonify(json_data)
5858

@@ -68,9 +68,8 @@ def education():
6868

6969
if request.method == 'POST':
7070
json_data = request.json
71-
if json_data['spell_check']:
72-
json_data = spell_check_json(json_data)
73-
71+
if json_data.get('spell_check') and isinstance(json_data.get('description'), str):
72+
json_data['description'] = spell_check(json_data['description'])
7473
return jsonify(json_data)
7574

7675
return jsonify({})
@@ -103,8 +102,8 @@ def skill():
103102

104103
if request.method == 'POST':
105104
json_data = request.json
106-
if json_data['spell_check']:
107-
json_data = spell_check_json(json_data)
105+
if json_data.get('spell_check') and isinstance(json_data.get('description'), str):
106+
json_data['description'] = spell_check(json_data['description'])
108107

109108
return jsonify(json_data)
110109

0 commit comments

Comments
 (0)