Alex commited on
Commit
60b8abf
·
verified ·
1 Parent(s): e02bee7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -73,6 +73,35 @@ def send_image2image_request(image, ratio, style, uuid_value, token):
73
  else:
74
  return f"Error: {response.status_code} - {response.text}"
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  # Function for Image-to-Image (Send POST request with an image and other parameters)
77
  def send_inpaint2image_request(image, mask, prompt, ratio, uuid_value, token, style):
78
  # Access the URL from Secrets (Private)
@@ -222,6 +251,17 @@ def create_interface():
222
  upload_submit_button = gr.Button("Get Upload URL")
223
  upload_submit_button.click(get_upload_url, inputs=[uuid_input], outputs=upload_url_output)
224
 
 
 
 
 
 
 
 
 
 
 
 
225
  with gr.Tab("Image Put"):
226
  # Inputs for Image Put
227
  image_input = gr.File(label="Upload Image") # Input for image file
 
73
  else:
74
  return f"Error: {response.status_code} - {response.text}"
75
 
76
+ # Function for Image-to-Image (Send POST request with an image and other parameters)
77
+ def send_enhance_request(image, uuid_value, token):
78
+ # Access the URL from Secrets (Private)
79
+ url = os.getenv('API_URL_ENHANCE') # Secret variable for the URL
80
+ if not url:
81
+ return "Error: API URL not set in environment secrets."
82
+
83
+ # Define the headers with the required values
84
+ headers = {
85
+ "Uid": uuid_value, # Using the provided UUID
86
+ "Versioncode": "16701",
87
+ "Accept-Version": "v1",
88
+ "Token": token, # Replace with the actual token
89
+ "Content-Type": "application/x-www-form-urlencoded"
90
+ }
91
+
92
+ # Define the values to be sent in the POST request
93
+ data = {
94
+ "image_name": image
95
+ }
96
+
97
+ response = requests.post(url, headers=headers, data=data)
98
+
99
+ # Return the response text or any relevant information
100
+ if response.status_code == 200:
101
+ return response.text
102
+ else:
103
+ return f"Error: {response.status_code} - {response.text}"
104
+
105
  # Function for Image-to-Image (Send POST request with an image and other parameters)
106
  def send_inpaint2image_request(image, mask, prompt, ratio, uuid_value, token, style):
107
  # Access the URL from Secrets (Private)
 
251
  upload_submit_button = gr.Button("Get Upload URL")
252
  upload_submit_button.click(get_upload_url, inputs=[uuid_input], outputs=upload_url_output)
253
 
254
+ with gr.Tab("Get Enhance"):
255
+ # Inputs for Get Upload URL
256
+ en_url = gr.Textbox(label="URL")
257
+ en_uuid = gr.Textbox(label="UUID ID") # Default UUID
258
+ en_token = gr.Textbox(label="Token ID")
259
+ en_output = gr.Textbox() # Output for the upload URL response
260
+
261
+ # Bind the get_upload_url function to the interface
262
+ en_submit_button = gr.Button("Get Upload URL")
263
+ en_button.click(send_enhance_request, inputs=[en_url, en_uuid, en_token], outputs=en_output)
264
+
265
  with gr.Tab("Image Put"):
266
  # Inputs for Image Put
267
  image_input = gr.File(label="Upload Image") # Input for image file