fantaxy commited on
Commit
b43300a
โ€ข
1 Parent(s): 6a468e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -8,7 +8,7 @@ import io
8
  import base64
9
 
10
  # ๋กœ๊น… ์„ค์ •
11
- logging.basicConfig(level=logging.INFO)
12
 
13
  # API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
14
  api_client = Client("http://211.233.58.202:7960/")
@@ -17,22 +17,27 @@ api_client = Client("http://211.233.58.202:7960/")
17
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
18
 
19
  # Imgur ํด๋ผ์ด์–ธํŠธ ID
20
- IMGUR_CLIENT_ID = "4990123196cbfcc"
21
 
22
  def upload_to_imgur(image_data):
23
  try:
24
  im_b64 = base64.b64encode(image_data).decode("utf-8")
25
 
26
  url = "https://api.imgur.com/3/image"
27
- payload = {'image': im_b64, 'type': 'base64'}
28
  headers = {'Authorization': f'Client-ID {IMGUR_CLIENT_ID}'}
29
 
30
  response = requests.post(url, headers=headers, data=payload)
 
 
 
31
  response.raise_for_status()
32
 
33
  return response.json()['data']['link']
34
- except Exception as e:
35
  logging.error(f"Failed to upload image to Imgur: {e}")
 
 
36
  return None
37
 
38
  def send_to_webhook(prompt, image_url):
@@ -90,8 +95,6 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
90
  return "Failed to generate image due to an error."
91
 
92
 
93
-
94
-
95
  css = """
96
  footer {
97
  visibility: hidden;
@@ -167,7 +170,6 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
167
  outputs=output_image
168
  )
169
 
170
- # ... (๋‚˜๋จธ์ง€ ์ฝ”๋“œ๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€)
171
-
172
  if __name__ == "__main__":
 
173
  demo.launch()
 
8
  import base64
9
 
10
  # ๋กœ๊น… ์„ค์ •
11
+ logging.basicConfig(level=logging.DEBUG) # DEBUG ๋ ˆ๋ฒจ๋กœ ๋ณ€๊ฒฝ
12
 
13
  # API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
14
  api_client = Client("http://211.233.58.202:7960/")
 
17
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
18
 
19
  # Imgur ํด๋ผ์ด์–ธํŠธ ID
20
+ IMGUR_CLIENT_ID = "์—ฌ๊ธฐ์—_๋‹น์‹ ์˜_IMGUR_CLIENT_ID๋ฅผ_์ž…๋ ฅํ•˜์„ธ์š”"
21
 
22
  def upload_to_imgur(image_data):
23
  try:
24
  im_b64 = base64.b64encode(image_data).decode("utf-8")
25
 
26
  url = "https://api.imgur.com/3/image"
27
+ payload = {'image': im_b64}
28
  headers = {'Authorization': f'Client-ID {IMGUR_CLIENT_ID}'}
29
 
30
  response = requests.post(url, headers=headers, data=payload)
31
+ logging.debug(f"Imgur API response status: {response.status_code}")
32
+ logging.debug(f"Imgur API response content: {response.text}")
33
+
34
  response.raise_for_status()
35
 
36
  return response.json()['data']['link']
37
+ except requests.exceptions.RequestException as e:
38
  logging.error(f"Failed to upload image to Imgur: {e}")
39
+ if hasattr(e, 'response'):
40
+ logging.error(f"Response content: {e.response.text}")
41
  return None
42
 
43
  def send_to_webhook(prompt, image_url):
 
95
  return "Failed to generate image due to an error."
96
 
97
 
 
 
98
  css = """
99
  footer {
100
  visibility: hidden;
 
170
  outputs=output_image
171
  )
172
 
 
 
173
  if __name__ == "__main__":
174
+ logging.info(f"Starting application with Imgur Client ID: {IMGUR_CLIENT_ID[:5]}...") # ๋ณด์•ˆ์„ ์œ„ํ•ด ์ „์ฒด ID๋ฅผ ๋กœ๊น…ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค
175
  demo.launch()