Spaces:
Sleeping
Sleeping
Change
Browse files- SampleCode/SampleCall.py +30 -0
- SampleCode/SampleDbConnection.py +23 -0
- SampleCode/SamplephpCall.php +39 -0
- SampleCode/ca.pem +25 -0
- SampleCode/index.php +21 -0
SampleCode/SampleCall.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
SampleCode/SampleDbConnection.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pymysql
|
2 |
+
|
3 |
+
timeout = 10
|
4 |
+
db_params = {}
|
5 |
+
connection = pymysql.connect(
|
6 |
+
charset="utf8mb4",
|
7 |
+
connect_timeout=timeout,
|
8 |
+
cursorclass=pymysql.cursors.DictCursor,
|
9 |
+
db="defaultdb",
|
10 |
+
host="mysql-anu-xboxgames1900-aebf.a.aivencloud.com",
|
11 |
+
password="AVNS_TGfs_uHRKteMjB9pFnq",
|
12 |
+
read_timeout=timeout,
|
13 |
+
port=25227,
|
14 |
+
user="avnadmin",
|
15 |
+
write_timeout=timeout,
|
16 |
+
)
|
17 |
+
|
18 |
+
try:
|
19 |
+
cursor = connection.cursor()
|
20 |
+
cursor.execute("SELECT * FROM skillmaster")
|
21 |
+
print(cursor.fetchall())
|
22 |
+
finally:
|
23 |
+
connection.close()
|
SampleCode/SamplephpCall.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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);
|
9 |
+
|
10 |
+
// Initialize cURL
|
11 |
+
$curl = curl_init();
|
12 |
+
|
13 |
+
// Set cURL options
|
14 |
+
curl_setopt_array($curl, array(
|
15 |
+
CURLOPT_URL => $url,
|
16 |
+
CURLOPT_RETURNTRANSFER => true,
|
17 |
+
CURLOPT_POST => true,
|
18 |
+
CURLOPT_POSTFIELDS => array(
|
19 |
+
'file' => new CURLFile($file_path), // Attach the file
|
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
|
36 |
+
//php samplephpcall.php
|
37 |
+
curl_close($curl);
|
38 |
+
?>
|
39 |
+
|
SampleCode/ca.pem
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN CERTIFICATE-----
|
2 |
+
MIIEQTCCAqmgAwIBAgIUeOk/j5D8tDsrzwYSvjqXMEdi79UwDQYJKoZIhvcNAQEM
|
3 |
+
BQAwOjE4MDYGA1UEAwwvNjllMTExOTQtNjRmNy00YjYxLTgzMDctYTQyMjU2NGU5
|
4 |
+
NTNhIFByb2plY3QgQ0EwHhcNMjQwMzI0MDYyMzMzWhcNMzQwMzIyMDYyMzMzWjA6
|
5 |
+
MTgwNgYDVQQDDC82OWUxMTE5NC02NGY3LTRiNjEtODMwNy1hNDIyNTY0ZTk1M2Eg
|
6 |
+
UHJvamVjdCBDQTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAMqtfbv+
|
7 |
+
233UB6p29LijiBLmVMAT91c6MXQJ13HCeghcjgBACLabARu2SMohGMEdJOVhdbZK
|
8 |
+
aNU5YEPZayWQri2Xqrf7AFF/0/M+W7nAvFebs7RJ0k0AY80sih5F4LxgKy6CYhVE
|
9 |
+
Ir+TNfO5hrB/qFc2BR8rAq2zm+qHK4NgJQ9s36+8JOphv4BRCt8xc/kkX2jnGFw5
|
10 |
+
pWZV7/CXbymaMjk8WnSyRvYoMxk4FBewZshbVJX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|
SampleCode/index.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$uri = "mysql://avnadmin:AVNS_TGfs_uHRKteMjB9pFnq@mysql-anu-xboxgames1900-aebf.a.aivencloud.com:25227/defaultdb?ssl-mode=REQUIRED";
|
4 |
+
|
5 |
+
$fields = parse_url($uri);
|
6 |
+
|
7 |
+
// build the DSN including SSL settings
|
8 |
+
$conn = "mysql:";
|
9 |
+
$conn .= "host=" . $fields["host"];
|
10 |
+
$conn .= ";port=" . $fields["port"];;
|
11 |
+
$conn .= ";dbname=defaultdb";
|
12 |
+
$conn .= ";sslmode=verify-ca;sslrootcert=ca.pem";
|
13 |
+
|
14 |
+
try {
|
15 |
+
$db = new PDO($conn, $fields["user"], $fields["pass"]);
|
16 |
+
|
17 |
+
$stmt = $db->query("SELECT VERSION()");
|
18 |
+
print($stmt->fetch()[0]);
|
19 |
+
} catch (Exception $e) {
|
20 |
+
echo "Error: " . $e->getMessage();
|
21 |
+
}
|