Spaces:
Sleeping
Sleeping
import requests | |
import os | |
import time | |
# URL of the API endpoint | |
url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/" | |
def CallAPI(file_path): | |
# Open the file in binary mode | |
with open(file_path, "rb") as file: | |
# Prepare the file to be sent in the request | |
files = {"file": (file_path, file)} | |
# Additional parameters for the request | |
params = {"FileName": file_name} # Adjust FileName if necessary | |
start_time = time.time() | |
# Make the POST request | |
response = requests.post(url, files=files, params=params) | |
end_time = time.time() | |
total_time = end_time - start_time | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
print("_____________________________________________________") | |
print("Job description uploaded successfully.", file_name) | |
print("") | |
# Print the response from the API | |
print(response.text) | |
print("") | |
print("Total time:", total_time, "seconds") | |
print("_____________________________________________________") | |
else: | |
print("Failed to upload job description.") | |
print("Status code:", response.status_code) | |
print("Response:", response.text) | |
folderPath = "Data" | |
files = os.listdir(folderPath) | |
for file in files: | |
filePath = os.path.join(folderPath, file) | |
file_name = os.path.basename(filePath) | |
CallAPI(filePath) | |
# Path to the file you want to upload | |
#file_path = "data/python_developer.pdf" | |