Alex commited on
Commit
360c7e8
·
verified ·
1 Parent(s): 5b57936

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -145,6 +145,34 @@ def send_enhance_request(image, uuid_value, token):
145
  else:
146
  return f"Error: {response.status_code} - {response.text}"
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  def send_outpaint_request(image, canvas_info, uuid_value, token):
149
  # Access the URL from Secrets (Private)
150
  url = os.getenv('API_URL_OUT') # Secret variable for the URL
@@ -402,6 +430,17 @@ def create_interface():
402
  en_submit_button = gr.Button("Get Upload URL")
403
  en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
404
 
 
 
 
 
 
 
 
 
 
 
 
405
  with gr.Tab("Get OutPaint"):
406
  # Inputs for Get Upload URL
407
  out_url = gr.Textbox(label="URL")
 
145
  else:
146
  return f"Error: {response.status_code} - {response.text}"
147
 
148
+ def send_generate_prompt_request(image, uuid_value, token):
149
+ # Access the URL from Secrets (Private)
150
+ url = os.getenv('API_URL_PROMPT') # Secret variable for the URL
151
+ if not url:
152
+ return "Error: API URL not set in environment secrets."
153
+
154
+ # Define the headers with the required values
155
+ headers = {
156
+ "Uid": uuid_value, # Using the provided UUID
157
+ "Versioncode": "16701",
158
+ "Accept-Version": "v1",
159
+ "Token": token, # Replace with the actual token
160
+ "Content-Type": "application/x-www-form-urlencoded"
161
+ }
162
+
163
+ # Define the values to be sent in the POST request
164
+ data = {
165
+ "image_name": image
166
+ }
167
+
168
+ response = requests.post(url, headers=headers, data=data)
169
+
170
+ # Return the response text or any relevant information
171
+ if response.status_code == 200:
172
+ return response.text
173
+ else:
174
+ return f"Error: {response.status_code} - {response.text}"
175
+
176
  def send_outpaint_request(image, canvas_info, uuid_value, token):
177
  # Access the URL from Secrets (Private)
178
  url = os.getenv('API_URL_OUT') # Secret variable for the URL
 
430
  en_submit_button = gr.Button("Get Upload URL")
431
  en_submit_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
432
 
433
+ with gr.Tab("Get Prompt"):
434
+ # Inputs for Get Upload URL
435
+ gen_url = gr.Textbox(label="URL")
436
+ gen_uuid = gr.Textbox(label="UUID ID") # Default UUID
437
+ gen_token = gr.Textbox(label="Token ID")
438
+ gen_output = gr.Textbox() # Output for the upload URL response
439
+
440
+ # Bind the get_upload_url function to the interface
441
+ gen_submit_button = gr.Button("Get Upload URL")
442
+ gen_submit_button.click(send_generate_prompt_request, inputs=[gen_url, gen_uuid, gen_token], outputs=gen_output)
443
+
444
  with gr.Tab("Get OutPaint"):
445
  # Inputs for Get Upload URL
446
  out_url = gr.Textbox(label="URL")