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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
"""

from dataclasses import asdict

from flask import Flask, jsonify, request

from models import Education, Experience, Skill


app = Flask(__name__)

data = {
"experience": [
Experience(
1,
"Software Developer",
"A Cool Company",
"October 2022",
Expand Down Expand Up @@ -48,11 +51,37 @@ def experience():
Handle experience requests
"""
if request.method == "GET":
data_experiences = data["experience"]
data_experiences_response = [asdict(exp) for exp in data_experiences]
return jsonify(data_experiences_response), 200

if request.method == "POST":
user_input = request.get_json()
required_fields = [
"title",
"company",
"start_date",
"end_date",
"description",
"logo",
]
# Validating User Input
if not all(field in user_input for field in required_fields):
return jsonify({"error": "Missing required fields"}), 400

# Create a new Experience instance
# Using the length of the of the experience list and the index of the new experience
user_input["id"] = len(data["experience"]) + 1
new_experience = Experience(**user_input)
data["experience"].append(new_experience)
return jsonify({"index": new_experience.id - 1}), 201

return jsonify()

if request.method == "POST":
return jsonify({})


return jsonify({})


Expand All @@ -70,12 +99,19 @@ def get_single_experience(pk):
return jsonify({})



@app.route("/resume/education", methods=["GET", "POST"])
def education():
"""
Handles education requests
"""
if request.method == "GET":
return jsonify({})

if request.method == "POST":
return jsonify({})


'''
if request.method == 'GET':
existing_education_records = data["education"]
return jsonify(
Expand All @@ -86,6 +122,7 @@ def education():
), 200



if request.method == "POST":

body = request.get_json()
Expand Down Expand Up @@ -141,6 +178,7 @@ def skill():

new_skill = Skill(name, proficiency, logo)


data["skill"].append(new_skill)

return jsonify(
Expand Down
1 change: 1 addition & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Experience:
'''
Experience Class
'''
id: int
title: str
company: str
start_date: str
Expand Down
12 changes: 9 additions & 3 deletions test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_experience():
Check that it returns the new experience in that list
"""
example_experience = {
"id": 2,
"title": "Software Developer",
"company": "A Cooler Company",
"start_date": "October 2022",
Expand All @@ -30,7 +31,10 @@ def test_experience():
}

item_id = (
app.test_client().post("/resume/experience", json=example_experience).json["id"]
app.test_client()
.post("/resume/experience", json=example_experience)
.json["index"]

)
response = app.test_client().get("/resume/experience")
assert response.json[item_id] == example_experience
Expand Down Expand Up @@ -68,6 +72,7 @@ def test_skill():
"name": "JavaScript",
"proficiency": "2-4 years",
"logo": "example-logo.png",

}

item_id = app.test_client().post("/resume/skill", json=example_skill).json["id"]
Expand All @@ -81,10 +86,11 @@ def test_get_skill_by_id():
"name": "Blowing Bubbles an Fighting Crime",
"proficiency": "5+ years",
"logo": "some-logo.png"

}

item_id = app.test_client().post('/resume/skill',
json=example_skill).json['id']
item_id = app.test_client().post("/resume/skill", json=example_skill).json["id"]


response = app.test_client().get(f'/resume/skill/{item_id}')
data = response.json
Expand Down
Loading