openfree commited on
Commit
b71d3c6
·
verified ·
1 Parent(s): a12c1f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -35,14 +35,22 @@ def get_logs():
35
  import re
36
 
37
  def get_deployment_update(code):
38
- if not code or len(code.strip()) < 10:
39
- return gr.update(visible=False)
40
  clean_code = remove_code_block(code)
41
  result = deploy_to_vercel(clean_code)
 
42
  match = re.search(r'https?://[\\w\\-]+\\.vercel\\.app', result)
43
  if match:
44
- return gr.update(src=match.group(0), visible=True)
45
- return gr.update(visible=False)
 
 
 
 
 
 
 
 
 
46
 
47
  # ------------------------
48
  # 1) DEMO_LIST 및 SystemPrompt
@@ -869,15 +877,14 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
869
  )
870
  gr.HTML('<div class="help-text">💡 원하는 게임의 설명을 입력하세요. 예: "테트리스 게임 제작해줘."</div>')
871
 
872
- deploy_result_container = gr.IFrame(
873
- src="",
874
- visible=False,
875
- height=600,
876
- width="100%",
877
  elem_id="deploy_result_container",
878
  )
879
 
880
-
881
 
882
  # Code Drawer 열기/닫기
883
  codeBtn.click(lambda: gr.update(open=True), inputs=[], outputs=[code_drawer])
@@ -920,14 +927,14 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
920
  outputs=[sandbox, state_tab]
921
  )
922
 
923
-
924
-
925
  deploy_btn.click(
926
  fn=get_deployment_update,
927
  inputs=[code_output],
928
  outputs=[deploy_result_container]
929
  )
930
 
 
 
931
  # ------------------------
932
  # 9) 실행
933
  # ------------------------
 
35
  import re
36
 
37
  def get_deployment_update(code):
 
 
38
  clean_code = remove_code_block(code)
39
  result = deploy_to_vercel(clean_code)
40
+ # 배포 URL 추출
41
  match = re.search(r'https?://[\\w\\-]+\\.vercel\\.app', result)
42
  if match:
43
+ url = match.group(0)
44
+ # HTML 앵커로 링크 표시
45
+ return gr.update(
46
+ value=f'<a href="{url}" target="_blank">🚀 배포된 앱 열기:{url}</a>',
47
+ visible=True
48
+ )
49
+ return gr.update(
50
+ value=f'❌ 배포 URL을 찾을 수 없습니다.<br>결과: {html.escape(result)}',
51
+ visible=True
52
+ )
53
+
54
 
55
  # ------------------------
56
  # 1) DEMO_LIST 및 SystemPrompt
 
877
  )
878
  gr.HTML('<div class="help-text">💡 원하는 게임의 설명을 입력하세요. 예: "테트리스 게임 제작해줘."</div>')
879
 
880
+
881
+
882
+ deploy_result_container = gr.HTML(
883
+ value="아직 배포된 게임이 없습니다.",
884
+ visible=True,
885
  elem_id="deploy_result_container",
886
  )
887
 
 
888
 
889
  # Code Drawer 열기/닫기
890
  codeBtn.click(lambda: gr.update(open=True), inputs=[], outputs=[code_drawer])
 
927
  outputs=[sandbox, state_tab]
928
  )
929
 
 
 
930
  deploy_btn.click(
931
  fn=get_deployment_update,
932
  inputs=[code_output],
933
  outputs=[deploy_result_container]
934
  )
935
 
936
+
937
+
938
  # ------------------------
939
  # 9) 실행
940
  # ------------------------