From 48b93e7a823ef01966753db0c335440c111c4e73 Mon Sep 17 00:00:00 2001 From: iyz Date: Sun, 2 Feb 2025 13:18:37 -0500 Subject: [PATCH 1/3] add route for fetching a specific education by index --- app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 70efbd8..988baf5 100644 --- a/app.py +++ b/app.py @@ -53,12 +53,19 @@ def experience(): return jsonify({}) @app.route('/resume/education', methods=['GET', 'POST']) -def education(): +@app.route("/resume/education/", methods=["GET"]) +def education(index=None): ''' - Handles education requests + GET /resume/experience/ - Returns the experience at the given index ''' if request.method == 'GET': - return jsonify({}) + if index is None or 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': return jsonify({}) From 59d0e23cf7545248e323172a11fd6d89d4ff4389 Mon Sep 17 00:00:00 2001 From: iyz Date: Sun, 2 Feb 2025 13:26:01 -0500 Subject: [PATCH 2/3] add code for issue17, returning a specific education --- app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 70efbd8..4db6477 100644 --- a/app.py +++ b/app.py @@ -53,12 +53,19 @@ def experience(): return jsonify({}) @app.route('/resume/education', methods=['GET', 'POST']) -def education(): +@app.route("/resume/education/", methods=["GET"]) +def education(index=None): ''' - Handles education requests + GET /resume/education/ - Returns the education at the given index ''' if request.method == 'GET': - return jsonify({}) + if index is None or 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': return jsonify({}) From 62e8a761efde941bcf38005f8db40e54ad2b0ffb Mon Sep 17 00:00:00 2001 From: iyz Date: Sun, 2 Feb 2025 14:37:09 -0500 Subject: [PATCH 3/3] add logic to seperate GET reqs for specific education --- app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 4db6477..bf4dce8 100644 --- a/app.py +++ b/app.py @@ -58,8 +58,8 @@ def education(index=None): ''' GET /resume/education/ - Returns the education at the given index ''' - if request.method == 'GET': - if index is None or index < 0: + if request.method == 'GET' and index is not None: + if index < 0: return jsonify({"error": "Index must be a positive integer"}) try: