Spaces:
Sleeping
Sleeping
import requests | |
import os | |
import time | |
from pydantic import BaseModel | |
from SampleAddSkill import UserAddNewSkill | |
# URL of the API endpoint | |
url = "https://vaibhav84-resumeapi.hf.space/" | |
class AddSkillDetails(BaseModel): | |
SkillName: str = 'SkillName' | |
SkillType: str = 'Soft Skill' | |
SkillScore: int = 10 | |
class UpdateSkillDetails(BaseModel): | |
SkillName: str = 'SkillName' | |
SkillWeightage: int = -2 | |
def CallAPI(API): | |
# Make the POST request | |
response = requests.get(url + API) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
print("_____________________________________________________") | |
print("Skill Details") | |
print("") | |
# Print the response from the API | |
print(response.text) | |
print("") | |
print("_____________________________________________________") | |
else: | |
print("Failed to get skill details.") | |
print("Status code:", response.status_code) | |
print("Response:", response.text) | |
#RemoveSkillsByName | |
def CallRemoveAPI(API, SkillName): | |
params = {"SkillName": SkillName} | |
# Make the POST request | |
response = requests.delete(url + API,params=params) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
print("_____________________________________________________") | |
print("Skill Deleted ") | |
print("") | |
# Print the response from the API | |
print(response.text) | |
print("") | |
print("_____________________________________________________") | |
else: | |
print("Failed to delete skill details.") | |
print("Status code:", response.status_code) | |
print("Response:", response.text) | |
def CallUpdateSkillAPI(API, SkillName1, weight): | |
data = UpdateSkillDetails( | |
SkillName=SkillName1, | |
SkillWeightage=weight | |
) | |
print(data) | |
# Make the POST request | |
response = requests.put(url + API,json=data.dict()) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
print("_____________________________________________________") | |
print("Skill Updated ") | |
print("") | |
# Print the response from the API | |
print(response.text) | |
print("") | |
print("_____________________________________________________") | |
else: | |
print("Failed to update skill details.") | |
print("Status code:", response.status_code) | |
print("Response:", response.text) | |
def CallAddSkillAPI(API, SkillName1,skilltype, score): | |
UserAddNewSkill.AddNewSkill(url + API,SkillName1,skilltype,score) | |
print("Enter API number to call:") | |
print("1. GetAll Skill") | |
print("2. Remove Skill") | |
print("3. Update Skill") | |
print("4. Add Skill") | |
userinput = input() | |
if(userinput == "1"): | |
CallAPI('GetAllSkillDetails/') | |
elif(userinput == "2"): | |
print("Enter skill which you want to delete") | |
userinputskill = input() | |
CallRemoveAPI('RemoveSkillsByName',userinputskill) | |
elif(userinput == "3"): | |
print("Enter skill which you want to update") | |
userupdateskill = input() | |
print("Enter skill weightage you want to update") | |
userwskill = input() | |
CallUpdateSkillAPI('UpdateSkillDetails/',userupdateskill,userwskill) | |
elif(userinput == "4"): | |
print("Enter skill which you want to add") | |
uskill = input() | |
print("Enter skill type") | |
userskilltype = input() | |
print("Enter skill score") | |
userskillscore = input() | |
CallAddSkillAPI('AddSkillDetails/',uskill,userskilltype,userskillscore) | |
#UpdateSkillDetails | |