measmonysuon commited on
Commit
a12a6f2
1 Parent(s): 4a88bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -25,6 +25,8 @@ DEFAULT_STYLE = "3840 x 2160"
25
  logging.basicConfig(level=logging.INFO)
26
  logger = logging.getLogger(__name__)
27
 
 
 
28
  def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
29
  resolution = resolutions.get(resolution_key, (1024, 1024))
30
  width, height = resolution
@@ -80,7 +82,7 @@ def get_user_points(user_chat_id):
80
  def retrieve_user_points(user_chat_id):
81
  """Retrieve user points and display them."""
82
  points = get_user_points(user_chat_id)
83
- if points == "User not found":
84
  return "Please register with @myexpsupportBot", ""
85
  return f"Your current points: {points}", points
86
 
@@ -117,7 +119,7 @@ def gradio_interface(prompt, resolution_key, user_chat_id):
117
  def handle_generate_image(prompt, resolution_key, user_chat_id):
118
  points = get_user_points(user_chat_id)
119
 
120
- if points == "User not found":
121
  # If user is not found, update points_output with the registration message
122
  return None, "Please register with @myexpsupportBot"
123
 
@@ -178,12 +180,12 @@ def create_gradio_interface(user_chat_id):
178
  # Set up interactions for the points retrieval
179
  get_points_button.click(
180
  fn=lambda url: (
181
- extract_user_chat_id_from_url(url), # Extract user_chat_id
182
- retrieve_user_points(extract_user_chat_id_from_url(url))[0] # Retrieve points based on extracted user_chat_id
 
183
  ),
184
- inputs=[user_chat_id_input],
185
- outputs=[points_output] # Update user_chat_id_input and points_outpu
186
-
187
  )
188
  gr.HTML("""
189
  <style>
 
25
  logging.basicConfig(level=logging.INFO)
26
  logger = logging.getLogger(__name__)
27
 
28
+ url = 'https://measmonysuon-imagen.hf.space/?user_chat_id=00000000'
29
+
30
  def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
31
  resolution = resolutions.get(resolution_key, (1024, 1024))
32
  width, height = resolution
 
82
  def retrieve_user_points(user_chat_id):
83
  """Retrieve user points and display them."""
84
  points = get_user_points(user_chat_id)
85
+ if points == "Guest":
86
  return "Please register with @myexpsupportBot", ""
87
  return f"Your current points: {points}", points
88
 
 
119
  def handle_generate_image(prompt, resolution_key, user_chat_id):
120
  points = get_user_points(user_chat_id)
121
 
122
+ if points == "Guest":
123
  # If user is not found, update points_output with the registration message
124
  return None, "Please register with @myexpsupportBot"
125
 
 
180
  # Set up interactions for the points retrieval
181
  get_points_button.click(
182
  fn=lambda url: (
183
+ (user_chat_id := extract_user_chat_id_from_url(url)),
184
+ points := retrieve_user_points(user_chat_id)[0], # Retrieve points based on extracted user_chat_id
185
+ (user_chat_id, points)
186
  ),
187
+ inputs=[gr.Textbox(default="https://measmonysuon-imagen.hf.space/?user_chat_id=00000000")], # Use a default URL or let it be dynamic
188
+ outputs=[user_chat_id_input, points_output] # Update both outputs
 
189
  )
190
  gr.HTML("""
191
  <style>