ginipick commited on
Commit
abbf372
Β·
verified Β·
1 Parent(s): 5199ff1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -86,31 +86,33 @@ def get_app_py_content(space_id: str) -> str:
86
  response = requests.get(app_py_url, headers=get_headers())
87
  if response.status_code == 200:
88
  content = response.text
89
- if len(content) > 1000: # λ‚΄μš©μ΄ λ„ˆλ¬΄ κΈΈλ©΄ μž˜λΌλƒ…λ‹ˆλ‹€
90
- content = content[:1000] + "... (content truncated)"
91
  return content
92
  else:
93
  return f"app.py file not found or inaccessible for space: {space_id}"
94
  except requests.RequestException:
95
  return f"Error fetching app.py content for space: {space_id}"
96
-
97
  def on_select(space):
98
  try:
99
  summary = summarize_space(space)
100
  app_content = get_app_py_content(space['id'])
101
- screenshot = take_screenshot(space['url'])
102
  info = f"μ„ νƒλœ Space: {space['name']} (ID: {space['id']})\n"
103
  info += f"Author: {space['author']}\n"
104
  info += f"Likes: {space['likes']}\n"
105
  info += f"URL: {space['url']}\n\n"
106
- info += f"μš”μ•½:\n{summary}"
107
- return info, app_content, screenshot
 
108
  except Exception as e:
109
  print(f"Error in on_select: {str(e)}")
110
  print(traceback.format_exc())
111
- return f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}", "", Image.new('RGB', (1, 1))
112
 
113
  def take_screenshot(url):
 
114
  try:
115
  chrome_options = Options()
116
  chrome_options.add_argument("--headless")
@@ -158,18 +160,15 @@ def create_ui():
158
  button = gr.Button("클릭", elem_classes="minimal-button")
159
  space_rows.append((space_row, button, space))
160
 
161
-
162
  with gr.Column(scale=1):
163
- info_output = gr.Textbox(label="Space 정보 및 μš”μ•½", lines=16)
164
- screenshot_output = gr.Image(type="pil", label="Live ν™”λ©΄", height=360, width=540)
165
  app_py_content = gr.Code(language="python", label="app.py λ‚΄μš©")
166
 
167
-
168
  for _, button, space in space_rows:
169
- button.click(
170
  lambda s=space: on_select(s),
171
  inputs=[],
172
- outputs=[info_output, screenshot_output, app_py_content]
173
  )
174
 
175
 
 
86
  response = requests.get(app_py_url, headers=get_headers())
87
  if response.status_code == 200:
88
  content = response.text
89
+ if len(content) > 500: # λ‚΄μš©μ„ 500자둜 μ œν•œν•©λ‹ˆλ‹€
90
+ content = content[:497] + "..."
91
  return content
92
  else:
93
  return f"app.py file not found or inaccessible for space: {space_id}"
94
  except requests.RequestException:
95
  return f"Error fetching app.py content for space: {space_id}"
96
+
97
  def on_select(space):
98
  try:
99
  summary = summarize_space(space)
100
  app_content = get_app_py_content(space['id'])
101
+ screenshot_info = take_screenshot(space['url'])
102
  info = f"μ„ νƒλœ Space: {space['name']} (ID: {space['id']})\n"
103
  info += f"Author: {space['author']}\n"
104
  info += f"Likes: {space['likes']}\n"
105
  info += f"URL: {space['url']}\n\n"
106
+ info += f"μš”μ•½:\n{summary}\n\n"
107
+ info += f"Screenshot Info: {screenshot_info}"
108
+ return info, app_content
109
  except Exception as e:
110
  print(f"Error in on_select: {str(e)}")
111
  print(traceback.format_exc())
112
+ return f"였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€: {str(e)}", ""
113
 
114
  def take_screenshot(url):
115
+ return f"Screenshot functionality is disabled. URL: {url}"
116
  try:
117
  chrome_options = Options()
118
  chrome_options.add_argument("--headless")
 
160
  button = gr.Button("클릭", elem_classes="minimal-button")
161
  space_rows.append((space_row, button, space))
162
 
 
163
  with gr.Column(scale=1):
164
+ info_output = gr.Textbox(label="Space 정보 및 μš”μ•½", lines=20)
 
165
  app_py_content = gr.Code(language="python", label="app.py λ‚΄μš©")
166
 
 
167
  for _, button, space in space_rows:
168
+ button.click(
169
  lambda s=space: on_select(s),
170
  inputs=[],
171
+ outputs=[info_output, app_py_content]
172
  )
173
 
174