Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -83,7 +83,10 @@ def get_app_py_content(space_id: str) -> str:
|
|
83 |
try:
|
84 |
response = requests.get(app_py_url, headers=get_headers())
|
85 |
if response.status_code == 200:
|
86 |
-
|
|
|
|
|
|
|
87 |
else:
|
88 |
return f"app.py file not found or inaccessible for space: {space_id}"
|
89 |
except requests.RequestException:
|
@@ -117,8 +120,6 @@ def take_screenshot(url):
|
|
117 |
except Exception as e:
|
118 |
print(f"Screenshot error: {str(e)}")
|
119 |
return Image.new('RGB', (1, 1))
|
120 |
-
|
121 |
-
|
122 |
def create_ui():
|
123 |
try:
|
124 |
spaces_list = get_most_liked_spaces()
|
@@ -144,18 +145,21 @@ def create_ui():
|
|
144 |
gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
|
145 |
button = gr.Button("클릭", elem_classes="minimal-button")
|
146 |
space_rows.append((space_row, button, space))
|
147 |
-
|
|
|
148 |
with gr.Column(scale=1):
|
149 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=16)
|
150 |
screenshot_output = gr.Image(type="pil", label="Live 화면", height=360, width=540)
|
151 |
app_py_content = gr.Code(language="python", label="app.py 내용")
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
159 |
|
160 |
return demo
|
161 |
|
@@ -166,8 +170,10 @@ def create_ui():
|
|
166 |
|
167 |
if __name__ == "__main__":
|
168 |
try:
|
|
|
169 |
import subprocess
|
170 |
subprocess.run(["playwright", "install", "chromium"], check=True)
|
|
|
171 |
|
172 |
demo = create_ui()
|
173 |
demo.launch()
|
|
|
83 |
try:
|
84 |
response = requests.get(app_py_url, headers=get_headers())
|
85 |
if response.status_code == 200:
|
86 |
+
content = response.text
|
87 |
+
if len(content) > 1000: # 내용이 너무 길면 잘라냅니다
|
88 |
+
content = content[:1000] + "... (content truncated)"
|
89 |
+
return content
|
90 |
else:
|
91 |
return f"app.py file not found or inaccessible for space: {space_id}"
|
92 |
except requests.RequestException:
|
|
|
120 |
except Exception as e:
|
121 |
print(f"Screenshot error: {str(e)}")
|
122 |
return Image.new('RGB', (1, 1))
|
|
|
|
|
123 |
def create_ui():
|
124 |
try:
|
125 |
spaces_list = get_most_liked_spaces()
|
|
|
145 |
gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
|
146 |
button = gr.Button("클릭", elem_classes="minimal-button")
|
147 |
space_rows.append((space_row, button, space))
|
148 |
+
|
149 |
+
|
150 |
with gr.Column(scale=1):
|
151 |
info_output = gr.Textbox(label="Space 정보 및 요약", lines=16)
|
152 |
screenshot_output = gr.Image(type="pil", label="Live 화면", height=360, width=540)
|
153 |
app_py_content = gr.Code(language="python", label="app.py 내용")
|
154 |
|
155 |
+
|
156 |
+
for _, button, space in space_rows:
|
157 |
+
button.click(
|
158 |
+
lambda s=space: on_select(s),
|
159 |
+
inputs=[],
|
160 |
+
outputs=[info_output, screenshot_output, app_py_content]
|
161 |
+
)
|
162 |
+
|
163 |
|
164 |
return demo
|
165 |
|
|
|
170 |
|
171 |
if __name__ == "__main__":
|
172 |
try:
|
173 |
+
# Playwright 브라우저 및 의존성 설치
|
174 |
import subprocess
|
175 |
subprocess.run(["playwright", "install", "chromium"], check=True)
|
176 |
+
subprocess.run(["playwright", "install-deps"], check=True)
|
177 |
|
178 |
demo = create_ui()
|
179 |
demo.launch()
|