Vaibhav84 commited on
Commit
6a3e938
·
1 Parent(s): 55539ca

SampleCode

Browse files
SampleCode/SampleCall.py CHANGED
@@ -1,30 +1,42 @@
1
  import requests
2
  import os
3
-
4
  # URL of the API endpoint
5
  url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/"
6
 
7
- # Path to the file you want to upload
8
- file_path = "d:/hug/job_desc_front_end_engineer.pdf"
9
- file_name = os.path.basename(file_path)
10
-
11
  # Open the file in binary mode
12
- with open(file_path, "rb") as file:
13
- # Prepare the file to be sent in the request
14
- files = {"file": (file_path, file)}
15
 
16
- # Additional parameters for the request
17
- params = {"FileName": file_name} # Adjust FileName if necessary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- # Make the POST request
20
- response = requests.post(url, files=files, params=params)
21
 
22
- # Check if the request was successful (status code 200)
23
- if response.status_code == 200:
24
- print("Job description uploaded successfully.")
25
- # Print the response from the API
26
- print(response.text)
27
- else:
28
- print("Failed to upload job description.")
29
- print("Status code:", response.status_code)
30
- print("Response:", response.text)
 
1
  import requests
2
  import os
3
+ import time
4
  # URL of the API endpoint
5
  url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/"
6
 
7
+ def CallAPI(file_path):
 
 
 
8
  # Open the file in binary mode
9
+ with open(file_path, "rb") as file:
10
+ # Prepare the file to be sent in the request
11
+ files = {"file": (file_path, file)}
12
 
13
+ # Additional parameters for the request
14
+ params = {"FileName": file_name} # Adjust FileName if necessary
15
+ start_time = time.time()
16
+ # Make the POST request
17
+ response = requests.post(url, files=files, params=params)
18
+ end_time = time.time()
19
+ total_time = end_time - start_time
20
+ # Check if the request was successful (status code 200)
21
+ if response.status_code == 200:
22
+ print("Job description uploaded successfully.", file_name)
23
+ # Print the response from the API
24
+ print(response.text)
25
+ print("Total time:", total_time, "seconds")
26
+ else:
27
+ print("Failed to upload job description.")
28
+ print("Status code:", response.status_code)
29
+ print("Response:", response.text)
30
+
31
+ folderPath = "Data"
32
+ files = os.listdir(folderPath)
33
+ for file in files:
34
+
35
+ filePath = os.path.join(folderPath, file)
36
+ file_name = os.path.basename(filePath)
37
+ CallAPI(filePath)
38
+ # Path to the file you want to upload
39
+ #file_path = "data/python_developer.pdf"
40
+
41
 
 
 
42
 
 
 
 
 
 
 
 
 
 
SampleCode/SamplephpCall.php CHANGED
@@ -2,7 +2,7 @@
2
  // API endpoint URL
3
  $url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/";
4
  // Path to the file you want to upload
5
- $file_path = "d:/hug/job_desc_front_end_engineer.pdf";
6
 
7
  // Extract the filename from the file path
8
  $file_name = basename($file_path);
@@ -20,16 +20,22 @@ curl_setopt_array($curl, array(
20
  'FileName' => $file_name // Pass the filename parameter
21
  ),
22
  ));
23
-
24
  // Execute the cURL request
25
  $response = curl_exec($curl);
 
 
 
 
 
26
 
27
  // Check for errors
28
  if (curl_errno($curl)) {
29
  echo 'Error: ' . curl_error($curl);
30
  } else {
31
  // Print response
32
- echo $response;
 
33
  }
34
 
35
  // Close cURL
 
2
  // API endpoint URL
3
  $url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/";
4
  // Path to the file you want to upload
5
+ $file_path = "data/Java1.pdf";
6
 
7
  // Extract the filename from the file path
8
  $file_name = basename($file_path);
 
20
  'FileName' => $file_name // Pass the filename parameter
21
  ),
22
  ));
23
+ $start_time = microtime(true);
24
  // Execute the cURL request
25
  $response = curl_exec($curl);
26
+ // Measure the end time
27
+ $end_time = microtime(true);
28
+
29
+ // Calculate the total time taken
30
+ $total_time = $end_time - $start_time;
31
 
32
  // Check for errors
33
  if (curl_errno($curl)) {
34
  echo 'Error: ' . curl_error($curl);
35
  } else {
36
  // Print response
37
+ echo $response . " \n";
38
+ echo "Total time: " . $total_time . " seconds\n";
39
  }
40
 
41
  // Close cURL