measmonysuon commited on
Commit
92f9409
1 Parent(s): b26b5f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -64,6 +64,19 @@ def update_user_points(user_chat_id, points):
64
  except requests.RequestException as e:
65
  logger.error(f"Error updating user points via webhook: {e}")
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  def notify_webhook(user_chat_id):
68
  """Notify the webhook server about the points update."""
69
  webhook_url = f"{webhook_server}/notify_update"
@@ -128,7 +141,7 @@ def create_gradio_interface(user_chat_id):
128
  points_output = gr.Textbox(label="User Points", placeholder="User points will be displayed here")
129
 
130
  # Create the button to get user points
131
- get_points_button = gr.Button("Retrieve Your Points")
132
 
133
  # Create other components
134
  prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
 
64
  except requests.RequestException as e:
65
  logger.error(f"Error updating user points via webhook: {e}")
66
 
67
+ def get_user_points(user_chat_id):
68
+ """Retrieve the user's points from the Flask server."""
69
+ try:
70
+ response = requests.get(f"{webhook_server}/get_points", params={'user_chat_id': user_chat_id})
71
+ response.raise_for_status()
72
+ data = response.json()
73
+ if 'error' in data:
74
+ return "User not found"
75
+ return data.get('points', 0)
76
+ except requests.RequestException as e:
77
+ logger.error(f"Error retrieving user points: {e}")
78
+ return "Error retrieving points"
79
+
80
  def notify_webhook(user_chat_id):
81
  """Notify the webhook server about the points update."""
82
  webhook_url = f"{webhook_server}/notify_update"
 
141
  points_output = gr.Textbox(label="User Points", placeholder="User points will be displayed here")
142
 
143
  # Create the button to get user points
144
+ get_points_button = gr.Button("Get Your Points")
145
 
146
  # Create other components
147
  prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")