measmonysuon commited on
Commit
1f1e043
1 Parent(s): aed520d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -139,13 +139,6 @@ def create_gradio_interface(user_chat_id):
139
  resolution_dropdown
140
  generate_button
141
 
142
- def handle_get_points(user_chat_id):
143
- points = get_user_points(user_chat_id)
144
- if points >= 5:
145
- return points, gr.update(visible=True)
146
- else:
147
- return points, gr.update(visible=False)
148
-
149
  def handle_generate_image(prompt, resolution_key, user_chat_id):
150
  points = get_user_points(user_chat_id)
151
  if points >= 5:
@@ -163,11 +156,12 @@ def create_gradio_interface(user_chat_id):
163
  inputs=[prompt_input, resolution_dropdown, user_chat_id_input],
164
  outputs=[result_output, message_output]
165
  )
166
-
 
167
  get_points_button.click(
168
- fn=handle_get_points,
169
  inputs=[user_chat_id_input],
170
- outputs=[points_output, generate_button]
171
  )
172
 
173
  gr.HTML("""
@@ -182,7 +176,7 @@ def create_gradio_interface(user_chat_id):
182
 
183
  def launch_gradio():
184
  # Obtain the URL dynamically (from a configured environment variable or similar)
185
- url = 'https://measmonysuon-imagen.hf.space/?user_chat_id=75516649' # Replace with the actual URL or method to obtain it
186
  user_chat_id = extract_user_chat_id_from_url(url)
187
 
188
  # Pass the extracted user_chat_id to the Gradio interface
@@ -190,4 +184,4 @@ def launch_gradio():
190
  interface.launch()
191
 
192
  if __name__ == '__main__':
193
- launch_gradio()
 
139
  resolution_dropdown
140
  generate_button
141
 
 
 
 
 
 
 
 
142
  def handle_generate_image(prompt, resolution_key, user_chat_id):
143
  points = get_user_points(user_chat_id)
144
  if points >= 5:
 
156
  inputs=[prompt_input, resolution_dropdown, user_chat_id_input],
157
  outputs=[result_output, message_output]
158
  )
159
+
160
+ # Remove the get_points_button related interaction if it's not needed anymore
161
  get_points_button.click(
162
+ fn=lambda user_chat_id: get_user_points(user_chat_id),
163
  inputs=[user_chat_id_input],
164
+ outputs=points_output
165
  )
166
 
167
  gr.HTML("""
 
176
 
177
  def launch_gradio():
178
  # Obtain the URL dynamically (from a configured environment variable or similar)
179
+ url = 'https://measmonysuon-imagen.hf.space/?user_chat_id=You Don't have UID yet' # Replace with the actual URL or method to obtain it
180
  user_chat_id = extract_user_chat_id_from_url(url)
181
 
182
  # Pass the extracted user_chat_id to the Gradio interface
 
184
  interface.launch()
185
 
186
  if __name__ == '__main__':
187
+ launch_gradio())