first commit
This commit is contained in:
parent
b216a187bd
commit
f73c77f548
119 changed files with 4504 additions and 4829 deletions
41
backend/routes/cv.py
Normal file
41
backend/routes/cv.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from flask import Blueprint, jsonify, request, current_app
|
||||
from utils.data_loader import load_data
|
||||
from utils.json_crud import load_json, save_json, add_entry, delete_entry, update_entry
|
||||
from models.cv_model import CVModel
|
||||
import os
|
||||
|
||||
DATA_DIR = os.path.join(os.path.dirname(__file__), '../data')
|
||||
CV_FILE = os.path.join(DATA_DIR, 'cv.json')
|
||||
|
||||
cv_bp = Blueprint('cv', __name__, url_prefix='/api/cv')
|
||||
|
||||
@cv_bp.route('/', methods=['GET'])
|
||||
def get_cv():
|
||||
cv = load_data('cv.json')
|
||||
return jsonify(cv)
|
||||
|
||||
@cv_bp.route('/', methods=['POST'])
|
||||
def update_cv():
|
||||
#key = request.headers.get('x-api-key')
|
||||
#if key != current_app.config['API_KEY']:
|
||||
# return jsonify({
|
||||
# "error": "Unauthorized"
|
||||
# }), 401
|
||||
|
||||
data = request.json
|
||||
new_entry = CVModel(data).to_dict()
|
||||
cv = [new_entry]
|
||||
save_json(CV_FILE, cv)
|
||||
return jsonify(new_entry), 201
|
||||
|
||||
@cv_bp.route('/skills/', methods=['GET'])
|
||||
def get_skills():
|
||||
cv = load_data('cv.json')
|
||||
skills = cv[0].get('my_skills')
|
||||
return jsonify(skills)
|
||||
|
||||
@cv_bp.route('/about/', methods=['GET'])
|
||||
def get_about():
|
||||
cv = load_data('cv.json')
|
||||
about = cv[0].get('about_text')
|
||||
return jsonify(about)
|
||||
Loading…
Add table
Add a link
Reference in a new issue