fantaxy commited on
Commit
4614879
ยท
verified ยท
1 Parent(s): 75b58d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -1,10 +1,9 @@
1
-
2
  import gradio as gr
3
  from gradio_client import Client
4
  import os
5
  import logging
6
  import requests
7
-
8
  # ๋กœ๊น… ์„ค์ •
9
  logging.basicConfig(level=logging.INFO)
10
 
@@ -14,10 +13,18 @@ api_client = Client("http://211.233.58.202:7960/")
14
  # Zapier ์›นํ›… URL
15
  WEBHOOK_URL = "https://hooks.zapier.com/hooks/catch/14523965/264pyhj/"
16
 
17
- def send_to_webhook(prompt, image_url):
 
 
 
 
 
 
 
 
18
  payload = {
19
  "prompt": prompt,
20
- "image_url": image_url
21
  }
22
  try:
23
  response = requests.post(WEBHOOK_URL, json=payload)
@@ -51,8 +58,11 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
51
  # ์ด๋ฏธ์ง€ URL ์ƒ์„ฑ (์‹ค์ œ ์„œ๋ฒ„ URL๋กœ ๋ณ€๊ฒฝ ํ•„์š”)
52
  image_url = f"http://211.233.58.202:7960/file={image_path}"
53
 
 
 
 
54
  # ์›นํ›…์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก
55
- send_to_webhook(message, image_url)
56
 
57
  return image_url
58
  else:
@@ -61,8 +71,6 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
61
  logging.error("Error during API request: %s", str(e))
62
  return "Failed to generate image due to an error."
63
 
64
-
65
-
66
  css = """
67
  footer {
68
  visibility: hidden;
 
 
1
  import gradio as gr
2
  from gradio_client import Client
3
  import os
4
  import logging
5
  import requests
6
+ import base64
7
  # ๋กœ๊น… ์„ค์ •
8
  logging.basicConfig(level=logging.INFO)
9
 
 
13
  # Zapier ์›นํ›… URL
14
  WEBHOOK_URL = "https://hooks.zapier.com/hooks/catch/14523965/264pyhj/"
15
 
16
+
17
+ def download_image(image_url):
18
+ response = requests.get(image_url)
19
+ if response.status_code == 200:
20
+ return response.content
21
+ else:
22
+ raise Exception(f"Failed to download image: {response.status_code}")
23
+
24
+ def send_to_webhook(prompt, image_content):
25
  payload = {
26
  "prompt": prompt,
27
+ "image": base64.b64encode(image_content).decode('utf-8')
28
  }
29
  try:
30
  response = requests.post(WEBHOOK_URL, json=payload)
 
58
  # ์ด๋ฏธ์ง€ URL ์ƒ์„ฑ (์‹ค์ œ ์„œ๋ฒ„ URL๋กœ ๋ณ€๊ฒฝ ํ•„์š”)
59
  image_url = f"http://211.233.58.202:7960/file={image_path}"
60
 
61
+ # ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ
62
+ image_content = download_image(image_url)
63
+
64
  # ์›นํ›…์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก
65
+ send_to_webhook(message, image_content)
66
 
67
  return image_url
68
  else:
 
71
  logging.error("Error during API request: %s", str(e))
72
  return "Failed to generate image due to an error."
73
 
 
 
74
  css = """
75
  footer {
76
  visibility: hidden;