Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
c7bb18c
1
Parent(s):
60a5ff9
Update app.py
Browse files
app.py
CHANGED
@@ -47,8 +47,18 @@ def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
|
|
47 |
return None
|
48 |
|
49 |
def request_otp(user_chat_id):
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
def verify_otp(user_chat_id, otp):
|
54 |
response = requests.post(f"{webhook_server}/verify_otp", json={"user_chat_id": user_chat_id, "otp": otp})
|
|
|
47 |
return None
|
48 |
|
49 |
def request_otp(user_chat_id):
|
50 |
+
try:
|
51 |
+
response = requests.post(f"{webhook_server}/request_otp", json={"user_chat_id": user_chat_id})
|
52 |
+
response.raise_for_status() # Ensure we raise an exception for HTTP errors
|
53 |
+
logger.debug(f"Response status code: {response.status_code}")
|
54 |
+
logger.debug(f"Response content: {response.text}")
|
55 |
+
return response.json()
|
56 |
+
except requests.RequestException as e:
|
57 |
+
logger.error(f"Request exception: {e}")
|
58 |
+
return {"success": False, "error": str(e)}
|
59 |
+
except ValueError as e:
|
60 |
+
logger.error(f"JSON decode error: {e}")
|
61 |
+
return {"success": False, "error": "Invalid JSON response"}
|
62 |
|
63 |
def verify_otp(user_chat_id, otp):
|
64 |
response = requests.post(f"{webhook_server}/verify_otp", json={"user_chat_id": user_chat_id, "otp": otp})
|