Update app.py
Browse files
app.py
CHANGED
|
@@ -93,17 +93,21 @@ def on_select(space):
|
|
| 93 |
try:
|
| 94 |
summary = summarize_space(space)
|
| 95 |
app_content = get_app_py_content(space['id'])
|
| 96 |
-
screenshot = take_screenshot(space['url'])
|
| 97 |
info = f"μ νλ Space: {space['name']} (ID: {space['id']})\n"
|
| 98 |
info += f"Author: {space['author']}\n"
|
| 99 |
info += f"Likes: {space['likes']}\n"
|
| 100 |
info += f"URL: {space['url']}\n\n"
|
| 101 |
info += f"μμ½:\n{summary}"
|
| 102 |
-
return info, app_content,
|
| 103 |
except Exception as e:
|
| 104 |
print(f"Error in on_select: {str(e)}")
|
| 105 |
print(traceback.format_exc())
|
| 106 |
-
return f"μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}", "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
def take_screenshot(url):
|
| 109 |
try:
|
|
@@ -142,16 +146,18 @@ def create_ui():
|
|
| 142 |
|
| 143 |
with gr.Column(scale=1):
|
| 144 |
info_output = gr.Textbox(label="Space μ 보 λ° μμ½", lines=20)
|
| 145 |
-
screenshot_output = gr.Image(type="pil", label="
|
| 146 |
-
app_py_content = gr.Code(language="python", label="
|
|
|
|
| 147 |
|
| 148 |
for _, button, space in space_rows:
|
| 149 |
button.click(
|
| 150 |
lambda s=space: on_select(s),
|
| 151 |
-
|
| 152 |
-
|
| 153 |
)
|
| 154 |
|
|
|
|
| 155 |
|
| 156 |
return demo
|
| 157 |
|
|
|
|
| 93 |
try:
|
| 94 |
summary = summarize_space(space)
|
| 95 |
app_content = get_app_py_content(space['id'])
|
|
|
|
| 96 |
info = f"μ νλ Space: {space['name']} (ID: {space['id']})\n"
|
| 97 |
info += f"Author: {space['author']}\n"
|
| 98 |
info += f"Likes: {space['likes']}\n"
|
| 99 |
info += f"URL: {space['url']}\n\n"
|
| 100 |
info += f"μμ½:\n{summary}"
|
| 101 |
+
return info, app_content, space['url']
|
| 102 |
except Exception as e:
|
| 103 |
print(f"Error in on_select: {str(e)}")
|
| 104 |
print(traceback.format_exc())
|
| 105 |
+
return f"μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}", "", ""
|
| 106 |
+
|
| 107 |
+
def update_screenshot(url):
|
| 108 |
+
if url:
|
| 109 |
+
return take_screenshot(url)
|
| 110 |
+
return None
|
| 111 |
|
| 112 |
def take_screenshot(url):
|
| 113 |
try:
|
|
|
|
| 146 |
|
| 147 |
with gr.Column(scale=1):
|
| 148 |
info_output = gr.Textbox(label="Space μ 보 λ° μμ½", lines=20)
|
| 149 |
+
screenshot_output = gr.Image(type="pil", label="Live νλ©΄", height=360, width=600)
|
| 150 |
+
app_py_content = gr.Code(language="python", label="λ©μΈ μμ€μ½λ")
|
| 151 |
+
url_state = gr.State("")
|
| 152 |
|
| 153 |
for _, button, space in space_rows:
|
| 154 |
button.click(
|
| 155 |
lambda s=space: on_select(s),
|
| 156 |
+
inputs=[],
|
| 157 |
+
outputs=[info_output, app_py_content, url_state]
|
| 158 |
)
|
| 159 |
|
| 160 |
+
demo.load(update_screenshot, inputs=[url_state], outputs=[screenshot_output], every=5)
|
| 161 |
|
| 162 |
return demo
|
| 163 |
|