From 9ffb731d50e7cff105e54ce9b695a810f707dc26 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 2 Oct 2024 12:23:15 -0700 Subject: [PATCH 1/2] Implement API route to add new Experience --- app.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 70efbd8..e11d3de 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,7 @@ ''' Flask Application ''' -from flask import Flask, jsonify, request +from flask import Flask, jsonify, request # type: ignore from models import Experience, Education, Skill app = Flask(__name__) @@ -45,13 +45,21 @@ def experience(): Handle experience requests ''' if request.method == 'GET': - return jsonify() + experiences = {} + for idx, exp in enumerate(data['experience']): + experiences[str(idx)] = exp.__dict__ + return jsonify(experiences) if request.method == 'POST': - return jsonify({}) + experience_data = request.json + new_experience = Experience(**experience_data) + data['experience'].append(new_experience) + index = len(data['experience']) - 1 + return jsonify({'id': str(index)}), 201 return jsonify({}) + @app.route('/resume/education', methods=['GET', 'POST']) def education(): ''' From 917dd6b7e24de96234f503c817f228356817f6ef Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 2 Oct 2024 12:33:27 -0700 Subject: [PATCH 2/2] Implement API route to add new Experience updated --- app.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app.py b/app.py index e11d3de..d036c91 100644 --- a/app.py +++ b/app.py @@ -45,10 +45,7 @@ def experience(): Handle experience requests ''' if request.method == 'GET': - experiences = {} - for idx, exp in enumerate(data['experience']): - experiences[str(idx)] = exp.__dict__ - return jsonify(experiences) + return jsonify() if request.method == 'POST': experience_data = request.json