Skip to content

Commit

Permalink
Merge pull request #32 from iyilmaz24/issue17
Browse files Browse the repository at this point in the history
issue #17, feature: API route to return a specific Education
  • Loading branch information
Pradyuman7 authored Feb 7, 2025
2 parents 019780c + 7caaefc commit bf12394
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,29 @@ def spell_check():
})

@app.route("/resume/education", methods=["GET", "POST"])
def education():
@app.route("/resume/education/<int:index>", methods=["GET"])
def education(index=None):
'''
Handles education requests
GET /resume/education/<int:index> - Returns the education at the given index
'''

if request.method == 'GET':
return jsonify(data['education']), 200

if request.method == 'GET' and index is not None:
if index < 0:
return jsonify({"error": "Index must be a positive integer"})

try:
return jsonify(data["education"][index])
except IndexError:
return jsonify({"error": "Index out of range"})

if request.method == 'POST':
json_data = request.json
try:
validated_data = validate_education(json_data)
return jsonify(validated_data)
except ValueError as e:
return jsonify({"error": str(e)}), 400

return jsonify({})

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

0 comments on commit bf12394

Please sign in to comment.