Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -201,6 +201,8 @@ def analyze_space(url: str, progress=gr.Progress()):
|
|
201 |
print(traceback.format_exc())
|
202 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", None, ""
|
203 |
|
|
|
|
|
204 |
def create_ui():
|
205 |
try:
|
206 |
css = """
|
@@ -275,7 +277,7 @@ def create_ui():
|
|
275 |
app_py_content = gr.Code(language="python", label="app.py", lines=30)
|
276 |
requirements_tab = gr.TabItem("requirements.txt")
|
277 |
with requirements_tab:
|
278 |
-
requirements_content = gr.
|
279 |
|
280 |
with gr.TabItem("AI ์ฝ๋ฉ"):
|
281 |
chatbot = gr.Chatbot(label="๋ํ", type="messages")
|
@@ -332,8 +334,10 @@ def create_ui():
|
|
332 |
def open_file(file_path: str, space_id: str):
|
333 |
content = get_file_content(space_id, file_path)
|
334 |
file_name = file_path.split('/')[-1]
|
335 |
-
|
336 |
-
|
|
|
|
|
337 |
|
338 |
analyze_button.click(
|
339 |
analyze_space,
|
@@ -370,6 +374,21 @@ def create_ui():
|
|
370 |
outputs=[code_tabs, code_tabs]
|
371 |
)
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
return demo
|
374 |
|
375 |
except Exception as e:
|
|
|
201 |
print(traceback.format_exc())
|
202 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", None, ""
|
203 |
|
204 |
+
|
205 |
+
|
206 |
def create_ui():
|
207 |
try:
|
208 |
css = """
|
|
|
277 |
app_py_content = gr.Code(language="python", label="app.py", lines=30)
|
278 |
requirements_tab = gr.TabItem("requirements.txt")
|
279 |
with requirements_tab:
|
280 |
+
requirements_content = gr.Textbox(label="requirements.txt", lines=30)
|
281 |
|
282 |
with gr.TabItem("AI ์ฝ๋ฉ"):
|
283 |
chatbot = gr.Chatbot(label="๋ํ", type="messages")
|
|
|
334 |
def open_file(file_path: str, space_id: str):
|
335 |
content = get_file_content(space_id, file_path)
|
336 |
file_name = file_path.split('/')[-1]
|
337 |
+
if file_name == "requirements.txt":
|
338 |
+
return gr.Tabs.update(selected="requirements.txt"), gr.Textbox.update(value=content, label=file_name)
|
339 |
+
else:
|
340 |
+
return gr.Tabs.update(selected=file_name), gr.Code.update(value=content, language="python" if file_name.endswith('.py') else "plaintext", label=file_name)
|
341 |
|
342 |
analyze_button.click(
|
343 |
analyze_space,
|
|
|
374 |
outputs=[code_tabs, code_tabs]
|
375 |
)
|
376 |
|
377 |
+
# JavaScript ์ฝ๋๋ฅผ HTML์ ์ง์ ์ฝ์
|
378 |
+
gr.HTML("""
|
379 |
+
<script>
|
380 |
+
function openFile(path, spaceId) {
|
381 |
+
const filePathInput = document.querySelector('input[data-testid="file_path_input"]');
|
382 |
+
const spaceIdInput = document.querySelector('input[data-testid="space_id_input"]');
|
383 |
+
if (filePathInput && spaceIdInput) {
|
384 |
+
filePathInput.value = path;
|
385 |
+
spaceIdInput.value = spaceId;
|
386 |
+
filePathInput.dispatchEvent(new Event('change'));
|
387 |
+
}
|
388 |
+
}
|
389 |
+
</script>
|
390 |
+
""")
|
391 |
+
|
392 |
return demo
|
393 |
|
394 |
except Exception as e:
|