Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
7a19fc7
1
Parent(s):
3899742
Update app.py
Browse files
app.py
CHANGED
@@ -78,8 +78,16 @@ def request_otp(user_chat_id):
|
|
78 |
return {"success": False, "error": "Invalid JSON response"}
|
79 |
|
80 |
def verify_otp(user_chat_id, otp):
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
def retrieve_user_points(user_chat_id, otp):
|
85 |
# Verify OTP via Flask server
|
|
|
78 |
return {"success": False, "error": "Invalid JSON response"}
|
79 |
|
80 |
def verify_otp(user_chat_id, otp):
|
81 |
+
try:
|
82 |
+
response = requests.post(f"{webhook_server}/verify_otp", json={"user_chat_id": user_chat_id, "otp": otp})
|
83 |
+
response.raise_for_status() # Raise an exception for HTTP errors
|
84 |
+
return response.json().get("valid", False)
|
85 |
+
except requests.RequestException as e:
|
86 |
+
logger.error(f"Request exception: {e}")
|
87 |
+
return False
|
88 |
+
except ValueError as e:
|
89 |
+
logger.error(f"JSON decode error: {e}")
|
90 |
+
return False
|
91 |
|
92 |
def retrieve_user_points(user_chat_id, otp):
|
93 |
# Verify OTP via Flask server
|