-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
95 lines (81 loc) · 2.3 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'''
Flask Application
'''
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 = {
"experience": [
Experience("Software Developer",
"A Cool Company",
"October 2022",
"Present",
"Writing Python Code",
"example-logo.png")
],
"education": [
Education("Computer Science",
"University of Tech",
"September 2019",
"July 2022",
"80%",
"example-logo.png")
],
"skill": [
Skill("Python",
"1-2 Years",
"example-logo.png")
]
}
@app.route('/test')
def hello_world():
'''
Returns a JSON test message
'''
return jsonify({"message": "Hello, World!"})
@app.route('/resume/experience', methods=['GET', 'POST'])
def experience():
'''
Handle experience requests
'''
if request.method == 'GET':
return jsonify()
if request.method == 'POST':
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({})
@app.route('/resume/education', methods=['GET', 'POST'])
def education():
'''
Handles education requests
'''
if request.method == 'GET':
return jsonify({})
if request.method == 'POST':
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({})
@app.route('/resume/skill', methods=['GET', 'POST'])
def skill():
'''
Handles Skill requests
'''
if request.method == 'GET':
return jsonify({})
if request.method == 'POST':
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({})