Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
4107503
1
Parent(s):
5a4a86b
Update app.py
Browse files
app.py
CHANGED
@@ -53,7 +53,7 @@ def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
|
|
53 |
|
54 |
def update_user_points(user_chat_id, points):
|
55 |
"""Updates the user's points using a webhook."""
|
56 |
-
webhook_url = f"{webhook_server}/
|
57 |
payload = {
|
58 |
'user_chat_id': user_chat_id,
|
59 |
'points': points
|
@@ -108,8 +108,7 @@ def gradio_interface(prompt, resolution_key, user_chat_id):
|
|
108 |
if result and result[0]:
|
109 |
file_path = result[0][0].get('image')
|
110 |
if file_path and os.path.exists(file_path):
|
111 |
-
update_user_points(user_chat_id, 5) #
|
112 |
-
notify_webhook(user_chat_id) # Notify the webhook server
|
113 |
return file_path, "The image was generated successfully."
|
114 |
else:
|
115 |
return None, "The image file is not available. Please try again later."
|
@@ -133,7 +132,7 @@ def handle_generate_image(prompt, resolution_key, user_chat_id):
|
|
133 |
return None, "Insufficient points. Please get more points before generating an image."
|
134 |
|
135 |
|
136 |
-
def create_gradio_interface(
|
137 |
with gr.Blocks() as interface:
|
138 |
# Personalized HTML content
|
139 |
gr.HTML("""
|
@@ -172,7 +171,7 @@ def create_gradio_interface(user_chat_id):
|
|
172 |
|
173 |
# Set up interactions
|
174 |
generate_button.click(
|
175 |
-
fn=
|
176 |
inputs=[prompt_input, resolution_dropdown, user_chat_id_input],
|
177 |
outputs=[result_output, message_output]
|
178 |
)
|
@@ -180,10 +179,9 @@ def create_gradio_interface(user_chat_id):
|
|
180 |
get_points_button.click(
|
181 |
fn=retrieve_user_points,
|
182 |
inputs=[user_chat_id_input],
|
183 |
-
outputs=[points_output
|
184 |
)
|
185 |
|
186 |
-
|
187 |
gr.HTML("""
|
188 |
<style>
|
189 |
footer.svelte-1rjryqp {
|
|
|
53 |
|
54 |
def update_user_points(user_chat_id, points):
|
55 |
"""Updates the user's points using a webhook."""
|
56 |
+
webhook_url = f"{webhook_server}/update_user_points" # Ensure this URL is correct
|
57 |
payload = {
|
58 |
'user_chat_id': user_chat_id,
|
59 |
'points': points
|
|
|
108 |
if result and result[0]:
|
109 |
file_path = result[0][0].get('image')
|
110 |
if file_path and os.path.exists(file_path):
|
111 |
+
update_user_points(user_chat_id, -5) # Deduct 5 points for each image generated
|
|
|
112 |
return file_path, "The image was generated successfully."
|
113 |
else:
|
114 |
return None, "The image file is not available. Please try again later."
|
|
|
132 |
return None, "Insufficient points. Please get more points before generating an image."
|
133 |
|
134 |
|
135 |
+
def create_gradio_interface():
|
136 |
with gr.Blocks() as interface:
|
137 |
# Personalized HTML content
|
138 |
gr.HTML("""
|
|
|
171 |
|
172 |
# Set up interactions
|
173 |
generate_button.click(
|
174 |
+
fn=gradio_interface,
|
175 |
inputs=[prompt_input, resolution_dropdown, user_chat_id_input],
|
176 |
outputs=[result_output, message_output]
|
177 |
)
|
|
|
179 |
get_points_button.click(
|
180 |
fn=retrieve_user_points,
|
181 |
inputs=[user_chat_id_input],
|
182 |
+
outputs=[points_output] # Update points output
|
183 |
)
|
184 |
|
|
|
185 |
gr.HTML("""
|
186 |
<style>
|
187 |
footer.svelte-1rjryqp {
|