File size: 1,555 Bytes
c1e46eb
 
6a3e938
c1e46eb
 
 
6a3e938
c1e46eb
6a3e938
 
 
c1e46eb
6a3e938
 
 
 
 
 
 
 
 
d00da8f
6a3e938
d00da8f
6a3e938
 
d00da8f
6a3e938
d00da8f
6a3e938
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1e46eb
 
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
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"