Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -34,6 +34,9 @@ def get_logs():
|
|
34 |
|
35 |
import re
|
36 |
|
|
|
|
|
|
|
37 |
def get_deployment_update(code_md: str):
|
38 |
clean = remove_code_block(code_md)
|
39 |
result = deploy_to_vercel(clean)
|
@@ -549,36 +552,39 @@ def execute_code(query: str):
|
|
549 |
# ------------------------
|
550 |
# ── deploy 버튼용 함수 새로 작성 ─────────────────────────────
|
551 |
def deploy_and_show(code_md: str):
|
552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
clean = remove_code_block(code_md)
|
554 |
result = deploy_to_vercel(clean)
|
555 |
|
|
|
556 |
url_match = re.search(r"https?://[\\w-]+\\.vercel\\.app", result)
|
557 |
-
if url_match:
|
558 |
url = url_match.group(0)
|
559 |
|
560 |
-
|
561 |
-
|
|
|
562 |
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
)
|
568 |
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
# ── 실패 ──
|
576 |
-
md = f"❌ **배포 실패**\n\n```\n{result}\n```"
|
577 |
-
return (
|
578 |
-
gr.update(value=md, visible=True),
|
579 |
-
None,
|
580 |
-
gr.update(active_key='empty')
|
581 |
-
)
|
582 |
|
583 |
|
584 |
|
@@ -965,12 +971,8 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
|
|
965 |
outputs=[deploy_result_container]
|
966 |
)
|
967 |
|
968 |
-
|
969 |
-
|
970 |
-
inputs=[code_output],
|
971 |
-
outputs=[deploy_result_container, sandbox, state_tab]
|
972 |
-
)
|
973 |
-
|
974 |
# ------------------------
|
975 |
# 9) 실행
|
976 |
# ------------------------
|
|
|
34 |
|
35 |
import re
|
36 |
|
37 |
+
deploying_flag = False # 전역 플래그
|
38 |
+
|
39 |
+
|
40 |
def get_deployment_update(code_md: str):
|
41 |
clean = remove_code_block(code_md)
|
42 |
result = deploy_to_vercel(clean)
|
|
|
552 |
# ------------------------
|
553 |
# ── deploy 버튼용 함수 새로 작성 ─────────────────────────────
|
554 |
def deploy_and_show(code_md: str):
|
555 |
+
global deploying_flag
|
556 |
+
|
557 |
+
# ① 중복 클릭 차단 ---------------------------------
|
558 |
+
if deploying_flag:
|
559 |
+
return (gr.update(value="⏳ 이미 배포 중입니다...", visible=True),
|
560 |
+
None,
|
561 |
+
gr.update(active_key="empty"))
|
562 |
+
deploying_flag = True
|
563 |
+
|
564 |
+
# ② 코드 정리 & 배포 --------------------------------
|
565 |
clean = remove_code_block(code_md)
|
566 |
result = deploy_to_vercel(clean)
|
567 |
|
568 |
+
# ③ 결과 해석 ---------------------------------------
|
569 |
url_match = re.search(r"https?://[\\w-]+\\.vercel\\.app", result)
|
570 |
+
if url_match:
|
571 |
url = url_match.group(0)
|
572 |
|
573 |
+
md_out = f"✅ **배포 완료!**\n\n➡️ [열기]({url})"
|
574 |
+
iframe = (f"<iframe src='{url}' width='100%' height='920px' "
|
575 |
+
"style='border:none;'></iframe>")
|
576 |
|
577 |
+
deploying_flag = False
|
578 |
+
return (gr.update(value=md_out, visible=True),
|
579 |
+
iframe,
|
580 |
+
gr.update(active_key="render"))
|
|
|
581 |
|
582 |
+
# ④ 실패 처리 ---------------------------------------
|
583 |
+
md_err = f"❌ **배포 실패**\n\n```\n{result}\n```"
|
584 |
+
deploying_flag = False
|
585 |
+
return (gr.update(value=md_err, visible=True),
|
586 |
+
None,
|
587 |
+
gr.update(active_key="empty"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
588 |
|
589 |
|
590 |
|
|
|
971 |
outputs=[deploy_result_container]
|
972 |
)
|
973 |
|
974 |
+
|
975 |
+
deploy_result_container = gr.Markdown(value="", visible=False)
|
|
|
|
|
|
|
|
|
976 |
# ------------------------
|
977 |
# 9) 실행
|
978 |
# ------------------------
|