WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 25e6661

Browse files
authored
Merge branch 'main' into main
2 parents ac90f32 + 104384e commit 25e6661

File tree

2 files changed

+205
-57
lines changed

2 files changed

+205
-57
lines changed

app.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,29 @@ def delete_experience(item_id):
263263
data["experience"].pop(item_id)
264264
return jsonify({"message": "Experience has been deleted"}), 200
265265

266+
@app.route("/resume/experience/<int:item_id>", methods=["DELETE"])
267+
def delete_experience(item_id):
268+
"""
269+
Delete an experience by index.
270+
271+
Parameters
272+
----------
273+
item_id : int
274+
The index of the experience to delete.
275+
276+
Returns
277+
-------
278+
Response
279+
JSON message indicating success or error.
280+
Returns 404 if experience not found.
281+
Returns 400 if request is invalid.
282+
"""
283+
if item_id < 0 or item_id >= len(data["experience"]):
284+
return jsonify({"error": "Invalid request"}), 400
285+
data["experience"].pop(item_id)
286+
return jsonify({"message": "Experience has been deleted"}), 200
287+
288+
266289
@app.route("/resume/education", methods=["GET", "POST"])
267290
def education():
268291
"""
@@ -445,5 +468,28 @@ def skill():
445468
return jsonify({"error": "Method not allowed"}), 405
446469

447470

471+
@app.route("/resume/skill/<int:index>", methods=["GET"])
472+
def get_skill_by_index(index):
473+
"""
474+
Get a specific skill by index
475+
"""
476+
try:
477+
skill_index = data["skill"][index]
478+
return jsonify(skill_index), 200
479+
except IndexError:
480+
return jsonify({"error": "Skill not found"}), 404
481+
482+
483+
@app.route("/resume/skill/<int:index>", methods=["DELETE"])
484+
def delete_skill(index):
485+
"""
486+
Delete specific skill by index
487+
"""
488+
if 0 <= index < len(data["skill"]):
489+
data["skill"].pop(index)
490+
return jsonify({"message": "Successfully deleted skill"}), 200
491+
return jsonify({"error": "Skill not found"}), 404
492+
493+
448494
if __name__ == "__main__":
449495
app.run()

0 commit comments

Comments
 (0)