Skip to content

Commit

Permalink
remove implementation for delete_experience
Browse files Browse the repository at this point in the history
  • Loading branch information
FortunateOmonuwa committed Feb 11, 2025
1 parent 7cdf0ba commit c03602a
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,6 @@ def hello_world():
return jsonify({"message": "Hello, World!"})


@app.route("/resume/experience", methods=["GET", "POST"])
@app.route("/resume/experience/<int:index>", methods=["GET"])
def experience(index=None):
'''
Handle experience requests
GET: Returns all experiences or a specific experience by index
POST: Creates a new experience
'''
if request.method == "GET":
if index is not None:
try:
return jsonify(data["experience"][index])
except IndexError:
return jsonify({"error": "Experience not found"}), 404
return jsonify(data["experience"]), 200

if request.method == "POST":
try:
new_experience = request.get_json()
if not new_experience:
return jsonify({"error": "No data provided"}), 400
# validate required fields
required_fields = [
"title",
"company",
"start_date",
"end_date",
"description",
"logo",
]
if not all(field in new_experience for field in required_fields):
return jsonify({"error": "Missing required fields"}), 400

experience_obj = Experience(**new_experience)
data["experience"].append(experience_obj)
return jsonify({"id": len(data["experience"]) - 1}), 201
except TypeError as e:
return jsonify({"error": f"Invalid data format: {str(e)}"}), 400
except Exception as e:
return jsonify({"error": f"Internal error: {str(e)}"}), 500


return jsonify({"error": "Method not allowed"}), 405

@app.route('/resume/experience/<int:exp_id>', methods=['DELETE'])
def delete_experience(exp_id):
try:
if exp_id < 0 or exp_id >= len(data["experience"]):
return jsonify({"message": "Resource doesn't exist"}), 404
else:
data['experience'].pop(exp_id)
return jsonify({"message": "Experience Successfully Deleted"}), 200
except Exception as e:
return jsonify({"error": f"An error occurred: {str(e)}"}), 500


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

0 comments on commit c03602a

Please sign in to comment.