Skip to content

Commit

Permalink
Implemented validation into app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgtzg committed Feb 5, 2025
1 parent e46243d commit 50c6a26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.venv
.pytest_cache/
__pycache__
.vscode
.vscode
.env
23 changes: 19 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
from flask import Flask, jsonify, request
from models import Experience, Education, Skill

from validation import validate_experience, validate_education, validate_skill
app = Flask(__name__)

data = {
Expand Down Expand Up @@ -48,7 +48,12 @@ def experience():
return jsonify()

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

return jsonify({})

Expand All @@ -61,7 +66,12 @@ def education():
return jsonify({})

if request.method == 'POST':
return jsonify({})
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({})

Expand All @@ -75,6 +85,11 @@ def skill():
return jsonify({})

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

return jsonify({})

0 comments on commit 50c6a26

Please sign in to comment.