Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -936,18 +936,17 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
|
|
| 936 |
max_length=100000
|
| 937 |
)
|
| 938 |
gr.HTML('<div class="help-text">💡 원하는 게임의 설명을 입력하세요. 예: "테트리스 게임 제작해줘."</div>')
|
| 939 |
-
|
| 940 |
deploy_result_container = gr.HTML(
|
| 941 |
"""
|
| 942 |
<div class="deploy-section">
|
| 943 |
<div class="deploy-header">📤 배포 결과</div>
|
| 944 |
<div id="deploy-result-box" class="deploy-result-box">
|
| 945 |
-
|
| 946 |
</div>
|
| 947 |
</div>
|
| 948 |
"""
|
| 949 |
-
)
|
| 950 |
-
|
| 951 |
|
| 952 |
js_trigger = gr.HTML(elem_id="js-trigger", visible=False)
|
| 953 |
|
|
@@ -1019,13 +1018,19 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
|
|
| 1019 |
outputs=[sandbox, state_tab]
|
| 1020 |
)
|
| 1021 |
|
| 1022 |
-
# 실제 배포 로직
|
| 1023 |
def deploy_to_vercel(code: str):
|
| 1024 |
try:
|
| 1025 |
token = "A8IFZmgW2cqA4yUNlLPnci0N" # 실제 토큰 필요
|
| 1026 |
if not token:
|
| 1027 |
-
return
|
| 1028 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1029 |
project_name = ''.join(random.choice(string.ascii_lowercase) for i in range(6))
|
| 1030 |
deploy_url = "https://api.vercel.com/v13/deployments"
|
| 1031 |
headers = {
|
|
@@ -1061,18 +1066,42 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
|
|
| 1061 |
}
|
| 1062 |
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
| 1063 |
if deploy_response.status_code != 200:
|
| 1064 |
-
return
|
| 1065 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1066 |
deployment_url = f"https://{project_name}.vercel.app"
|
| 1067 |
time.sleep(5)
|
| 1068 |
-
|
| 1069 |
-
return
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1074 |
except Exception as e:
|
| 1075 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
|
| 1077 |
# handle_deploy
|
| 1078 |
def handle_deploy(code, deploy_status):
|
|
@@ -1175,14 +1204,21 @@ with gr.Blocks(css_paths=["app.css"], theme=theme) as demo:
|
|
| 1175 |
"url": ""
|
| 1176 |
}
|
| 1177 |
|
| 1178 |
-
|
|
|
|
| 1179 |
deploy_btn.click(
|
| 1180 |
-
fn=
|
| 1181 |
-
|
| 1182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1183 |
)
|
| 1184 |
|
| 1185 |
-
|
| 1186 |
# ------------------------
|
| 1187 |
# 8) 실제 실행
|
| 1188 |
# ------------------------
|
|
|
|
| 936 |
max_length=100000
|
| 937 |
)
|
| 938 |
gr.HTML('<div class="help-text">💡 원하는 게임의 설명을 입력하세요. 예: "테트리스 게임 제작해줘."</div>')
|
|
|
|
| 939 |
deploy_result_container = gr.HTML(
|
| 940 |
"""
|
| 941 |
<div class="deploy-section">
|
| 942 |
<div class="deploy-header">📤 배포 결과</div>
|
| 943 |
<div id="deploy-result-box" class="deploy-result-box">
|
| 944 |
+
<div class="no-deploy">아직 배포된 게임이 없습니다.</div>
|
| 945 |
</div>
|
| 946 |
</div>
|
| 947 |
"""
|
| 948 |
+
)
|
| 949 |
+
|
| 950 |
|
| 951 |
js_trigger = gr.HTML(elem_id="js-trigger", visible=False)
|
| 952 |
|
|
|
|
| 1018 |
outputs=[sandbox, state_tab]
|
| 1019 |
)
|
| 1020 |
|
|
|
|
| 1021 |
def deploy_to_vercel(code: str):
|
| 1022 |
try:
|
| 1023 |
token = "A8IFZmgW2cqA4yUNlLPnci0N" # 실제 토큰 필요
|
| 1024 |
if not token:
|
| 1025 |
+
return """
|
| 1026 |
+
<div class="deploy-section">
|
| 1027 |
+
<div class="deploy-error">
|
| 1028 |
+
<div class="error-icon">⚠️</div>
|
| 1029 |
+
<div class="error-message">Vercel 토큰이 설정되지 않았습니다.</div>
|
| 1030 |
+
</div>
|
| 1031 |
+
</div>
|
| 1032 |
+
"""
|
| 1033 |
+
|
| 1034 |
project_name = ''.join(random.choice(string.ascii_lowercase) for i in range(6))
|
| 1035 |
deploy_url = "https://api.vercel.com/v13/deployments"
|
| 1036 |
headers = {
|
|
|
|
| 1066 |
}
|
| 1067 |
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
| 1068 |
if deploy_response.status_code != 200:
|
| 1069 |
+
return f"""
|
| 1070 |
+
<div class="deploy-section">
|
| 1071 |
+
<div class="deploy-error">
|
| 1072 |
+
<div class="error-icon">⚠️</div>
|
| 1073 |
+
<div class="error-message">배포 실패: {deploy_response.text}</div>
|
| 1074 |
+
</div>
|
| 1075 |
+
</div>
|
| 1076 |
+
"""
|
| 1077 |
+
|
| 1078 |
deployment_url = f"https://{project_name}.vercel.app"
|
| 1079 |
time.sleep(5)
|
| 1080 |
+
|
| 1081 |
+
return f"""
|
| 1082 |
+
<div class="deploy-section">
|
| 1083 |
+
<div class="deploy-header">📤 배포 결과</div>
|
| 1084 |
+
<div class="deploy-success">
|
| 1085 |
+
<div class="success-icon">✅</div>
|
| 1086 |
+
<div class="success-message">배포 완료!</div>
|
| 1087 |
+
<div class="url-box">
|
| 1088 |
+
<a href="{deployment_url}" target="_blank">{deployment_url}</a>
|
| 1089 |
+
<button class="copy-btn" onclick="navigator.clipboard.writeText('{deployment_url}')">복사</button>
|
| 1090 |
+
</div>
|
| 1091 |
+
</div>
|
| 1092 |
+
</div>
|
| 1093 |
+
"""
|
| 1094 |
except Exception as e:
|
| 1095 |
+
return f"""
|
| 1096 |
+
<div class="deploy-section">
|
| 1097 |
+
<div class="deploy-error">
|
| 1098 |
+
<div class="error-icon">⚠️</div>
|
| 1099 |
+
<div class="error-message">배포 중 오류 발생: {str(e)}</div>
|
| 1100 |
+
</div>
|
| 1101 |
+
</div>
|
| 1102 |
+
"""
|
| 1103 |
+
|
| 1104 |
+
|
| 1105 |
|
| 1106 |
# handle_deploy
|
| 1107 |
def handle_deploy(code, deploy_status):
|
|
|
|
| 1204 |
"url": ""
|
| 1205 |
}
|
| 1206 |
|
| 1207 |
+
|
| 1208 |
+
|
| 1209 |
deploy_btn.click(
|
| 1210 |
+
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else """
|
| 1211 |
+
<div class="deploy-section">
|
| 1212 |
+
<div class="deploy-error">
|
| 1213 |
+
<div class="error-icon">⚠️</div>
|
| 1214 |
+
<div class="error-message">배포할 코드가 ���습니다. 먼저 게임 코드를 생성해주세요.</div>
|
| 1215 |
+
</div>
|
| 1216 |
+
</div>
|
| 1217 |
+
""",
|
| 1218 |
+
inputs=[code_output],
|
| 1219 |
+
outputs=[deploy_result_container]
|
| 1220 |
)
|
| 1221 |
|
|
|
|
| 1222 |
# ------------------------
|
| 1223 |
# 8) 실제 실행
|
| 1224 |
# ------------------------
|