Skip to content

Commit bf12394

Browse files
authored
Merge pull request #32 from iyilmaz24/issue17
issue #17, feature: API route to return a specific Education
2 parents 019780c + 7caaefc commit bf12394

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

app.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,29 @@ def spell_check():
8686
})
8787

8888
@app.route("/resume/education", methods=["GET", "POST"])
89-
def education():
89+
@app.route("/resume/education/<int:index>", methods=["GET"])
90+
def education(index=None):
9091
'''
91-
Handles education requests
92+
GET /resume/education/<int:index> - Returns the education at the given index
9293
'''
93-
94-
if request.method == 'GET':
95-
return jsonify(data['education']), 200
96-
94+
if request.method == 'GET' and index is not None:
95+
if index < 0:
96+
return jsonify({"error": "Index must be a positive integer"})
97+
98+
try:
99+
return jsonify(data["education"][index])
100+
except IndexError:
101+
return jsonify({"error": "Index out of range"})
102+
97103
if request.method == 'POST':
98104
json_data = request.json
99105
try:
100106
validated_data = validate_education(json_data)
101107
return jsonify(validated_data)
102108
except ValueError as e:
103109
return jsonify({"error": str(e)}), 400
110+
111+
return jsonify({})
104112

105113
@app.route('/resume/reword_description', methods=['GET'])
106114
def reword_description():

0 commit comments

Comments
 (0)