Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -793,6 +793,66 @@ def deploy_to_huggingface(code: str):
|
|
| 793 |
except Exception as e:
|
| 794 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 795 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 796 |
|
| 797 |
# Demo ์ธ์คํด์ค ์์ฑ
|
| 798 |
demo_instance = Demo()
|
|
@@ -982,14 +1042,17 @@ with gr.Blocks(css_paths="app.css",theme=theme) as demo:
|
|
| 982 |
outputs=[history]
|
| 983 |
)
|
| 984 |
|
| 985 |
-
|
|
|
|
|
|
|
| 986 |
deploy_btn.click(
|
| 987 |
-
fn=lambda code:
|
| 988 |
inputs=[code_output],
|
| 989 |
outputs=[deploy_result]
|
| 990 |
)
|
| 991 |
|
| 992 |
|
|
|
|
| 993 |
if __name__ == "__main__":
|
| 994 |
try:
|
| 995 |
demo_instance = Demo()
|
|
|
|
| 793 |
except Exception as e:
|
| 794 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 795 |
|
| 796 |
+
|
| 797 |
+
def deploy_to_vercel(code: str):
|
| 798 |
+
"""Vercel์ ์ฝ๋ ๋ฐฐํฌ"""
|
| 799 |
+
try:
|
| 800 |
+
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
| 801 |
+
if not token:
|
| 802 |
+
return "Vercel ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค."
|
| 803 |
+
|
| 804 |
+
# ํ๋ก์ ํธ ์ด๋ฆ ์์ฑ
|
| 805 |
+
project_name = ''.join(random.choice(string.ascii_lowercase) for i in range(6))
|
| 806 |
+
|
| 807 |
+
# Vercel API ์๋ํฌ์ธํธ
|
| 808 |
+
api_url = "https://api.vercel.com/v9/projects"
|
| 809 |
+
deploy_url = "https://api.vercel.com/v13/deployments"
|
| 810 |
+
|
| 811 |
+
# ํ๋ก์ ํธ ์์ฑ
|
| 812 |
+
headers = {
|
| 813 |
+
"Authorization": f"Bearer {token}",
|
| 814 |
+
"Content-Type": "application/json"
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
project_data = {
|
| 818 |
+
"name": project_name,
|
| 819 |
+
"framework": "static"
|
| 820 |
+
}
|
| 821 |
+
|
| 822 |
+
project_response = requests.post(api_url, headers=headers, json=project_data)
|
| 823 |
+
|
| 824 |
+
if project_response.status_code != 200:
|
| 825 |
+
return f"ํ๋ก์ ํธ ์์ฑ ์คํจ: {project_response.text}"
|
| 826 |
+
|
| 827 |
+
# index.html ํ์ผ ์์ฑ
|
| 828 |
+
files = {
|
| 829 |
+
"index.html": {
|
| 830 |
+
"content": code
|
| 831 |
+
}
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
# ๋ฐฐํฌ ์์ฒญ
|
| 835 |
+
deploy_data = {
|
| 836 |
+
"name": project_name,
|
| 837 |
+
"files": files,
|
| 838 |
+
"projectId": project_response.json()["id"],
|
| 839 |
+
"target": "production"
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
| 843 |
+
|
| 844 |
+
if deploy_response.status_code != 200:
|
| 845 |
+
return f"๋ฐฐํฌ ์คํจ: {deploy_response.text}"
|
| 846 |
+
|
| 847 |
+
# ๋ฐฐํฌ URL ์์ฑ
|
| 848 |
+
deployment_url = f"https://{project_name}.vercel.app"
|
| 849 |
+
|
| 850 |
+
return f"""๋ฐฐํฌ ์๋ฃ! <a href="{deployment_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์ฌ๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ ์ด๊ธฐ</a>"""
|
| 851 |
+
|
| 852 |
+
except Exception as e:
|
| 853 |
+
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
| 854 |
+
|
| 855 |
+
|
| 856 |
|
| 857 |
# Demo ์ธ์คํด์ค ์์ฑ
|
| 858 |
demo_instance = Demo()
|
|
|
|
| 1042 |
outputs=[history]
|
| 1043 |
)
|
| 1044 |
|
| 1045 |
+
|
| 1046 |
+
|
| 1047 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ ์์
|
| 1048 |
deploy_btn.click(
|
| 1049 |
+
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "์ฝ๋๊ฐ ์์ต๋๋ค.",
|
| 1050 |
inputs=[code_output],
|
| 1051 |
outputs=[deploy_result]
|
| 1052 |
)
|
| 1053 |
|
| 1054 |
|
| 1055 |
+
|
| 1056 |
if __name__ == "__main__":
|
| 1057 |
try:
|
| 1058 |
demo_instance = Demo()
|