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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -9
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- import re
3
  import random
4
  import time
5
  import html
@@ -33,6 +32,17 @@ def get_logs():
33
  """StringIO에 쌓인 로그를 문자열로 반환"""
34
  return log_stream.getvalue()
35
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  # ------------------------
38
  # 1) DEMO_LIST 및 SystemPrompt
@@ -859,14 +869,15 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
859
  )
860
  gr.HTML('<div class="help-text">💡 원하는 게임의 설명을 입력하세요. 예: "테트리스 게임 제작해줘."</div>')
861
 
862
-
863
-
864
- deploy_result_container = gr.Markdown(
865
- value="아직 배포된 게임이 없습니다.",
866
- unsafe_allow_html=True,
867
  elem_id="deploy_result_container",
868
  )
869
 
 
870
 
871
  # Code Drawer 열기/닫기
872
  codeBtn.click(lambda: gr.update(open=True), inputs=[], outputs=[code_drawer])
@@ -910,14 +921,13 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
910
  )
911
 
912
 
 
913
  deploy_btn.click(
914
- # use handle_deploy_legacy to render the iframe/banner HTML
915
- fn=lambda code: handle_deploy_legacy(code) if code else "<div style='color:red;'>배포할 코드가 없습니다.</div>",
916
  inputs=[code_output],
917
  outputs=[deploy_result_container]
918
  )
919
 
920
-
921
  # ------------------------
922
  # 9) 실행
923
  # ------------------------
 
1
  import os
 
2
  import random
3
  import time
4
  import html
 
32
  """StringIO에 쌓인 로그를 문자열로 반환"""
33
  return log_stream.getvalue()
34
 
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
  )
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])
 
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
  # ------------------------