Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,29 +15,30 @@ ASSISTANT_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/reso
|
|
| 15 |
USER_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/usr.png"
|
| 16 |
|
| 17 |
def authorize(api_key):
|
| 18 |
-
print(f"{api_key}")
|
| 19 |
test_data = {
|
| 20 |
"kind": "PER_DATA",
|
| 21 |
-
"identificator":
|
| 22 |
}
|
| 23 |
test_headers = {
|
| 24 |
-
"Authorization": f"{API_TOKEN}",
|
| 25 |
"Content-Type": "application/json",
|
| 26 |
}
|
| 27 |
|
|
|
|
| 28 |
try:
|
|
|
|
|
|
|
|
|
|
| 29 |
response = requests.post("https://polrambora.com/api/v2/checkSDPA", headers=test_headers, data=json.dumps(test_data))
|
| 30 |
|
|
|
|
|
|
|
| 31 |
if response.status_code == 200:
|
| 32 |
response_json = response.json()
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
return True
|
| 36 |
-
else:
|
| 37 |
-
print("Authorization failed: 'identificator' not found in response.")
|
| 38 |
-
return False
|
| 39 |
else:
|
| 40 |
-
print(f"
|
| 41 |
return False
|
| 42 |
except Exception as e:
|
| 43 |
print(f"Exception occurred: {str(e)}")
|
|
|
|
| 15 |
USER_PIC_PATH = "https://huggingface.co/spaces/PLRMB/P-MSQ-API-PREVIEW/resolve/main/usr.png"
|
| 16 |
|
| 17 |
def authorize(api_key):
|
|
|
|
| 18 |
test_data = {
|
| 19 |
"kind": "PER_DATA",
|
| 20 |
+
"identificator": api_key
|
| 21 |
}
|
| 22 |
test_headers = {
|
| 23 |
+
"Authorization": f"Bearer {API_TOKEN}",
|
| 24 |
"Content-Type": "application/json",
|
| 25 |
}
|
| 26 |
|
| 27 |
+
print("Preparing to send the request...")
|
| 28 |
try:
|
| 29 |
+
print(f"Request Data: {test_data}")
|
| 30 |
+
print(f"Request Headers: {test_headers}")
|
| 31 |
+
|
| 32 |
response = requests.post("https://polrambora.com/api/v2/checkSDPA", headers=test_headers, data=json.dumps(test_data))
|
| 33 |
|
| 34 |
+
print("Request sent!")
|
| 35 |
+
|
| 36 |
if response.status_code == 200:
|
| 37 |
response_json = response.json()
|
| 38 |
+
print(f"Response: {response_json}")
|
| 39 |
+
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
else:
|
| 41 |
+
print(f"Failed request - Status code: {response.status_code}, Response: {response.text}")
|
| 42 |
return False
|
| 43 |
except Exception as e:
|
| 44 |
print(f"Exception occurred: {str(e)}")
|