Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -775,22 +775,33 @@ def deploy_to_vercel(code: str):
|
|
| 775 |
"Content-Type": "application/json"
|
| 776 |
}
|
| 777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 778 |
# ๋ฐฐํฌํ ํ์ผ ๋ฐ์ดํฐ ๊ตฌ์กฐ
|
| 779 |
files = [
|
| 780 |
{
|
| 781 |
"file": "index.html",
|
| 782 |
"data": code
|
|
|
|
|
|
|
|
|
|
|
|
|
| 783 |
}
|
| 784 |
]
|
| 785 |
|
| 786 |
-
# ํ๋ก์ ํธ ์ค์
|
| 787 |
project_settings = {
|
| 788 |
-
"devCommand": None,
|
| 789 |
-
"installCommand": None,
|
| 790 |
"buildCommand": None,
|
| 791 |
"outputDirectory": ".",
|
| 792 |
-
"
|
| 793 |
-
"framework": "vite" # ํ์ฉ๋ ํ๋ ์์ํฌ ์ค 'vite' ์ฌ์ฉ
|
| 794 |
}
|
| 795 |
|
| 796 |
# ๋ฐฐํฌ ์์ฒญ ๋ฐ์ดํฐ
|
|
@@ -799,7 +810,7 @@ def deploy_to_vercel(code: str):
|
|
| 799 |
"files": files,
|
| 800 |
"target": "production",
|
| 801 |
"projectSettings": project_settings,
|
| 802 |
-
"framework": "
|
| 803 |
}
|
| 804 |
|
| 805 |
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
|
@@ -807,10 +818,14 @@ def deploy_to_vercel(code: str):
|
|
| 807 |
if deploy_response.status_code != 200:
|
| 808 |
return f"๋ฐฐํฌ ์คํจ: {deploy_response.text}"
|
| 809 |
|
| 810 |
-
#
|
| 811 |
-
|
|
|
|
| 812 |
|
| 813 |
-
|
|
|
|
|
|
|
|
|
|
| 814 |
|
| 815 |
except Exception as e:
|
| 816 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|
|
|
|
| 775 |
"Content-Type": "application/json"
|
| 776 |
}
|
| 777 |
|
| 778 |
+
# package.json ํ์ผ ์์ฑ (Vite ์ค์ )
|
| 779 |
+
package_json = {
|
| 780 |
+
"name": project_name,
|
| 781 |
+
"version": "1.0.0",
|
| 782 |
+
"scripts": {
|
| 783 |
+
"build": "vite build",
|
| 784 |
+
"dev": "vite"
|
| 785 |
+
}
|
| 786 |
+
}
|
| 787 |
+
|
| 788 |
# ๋ฐฐํฌํ ํ์ผ ๋ฐ์ดํฐ ๊ตฌ์กฐ
|
| 789 |
files = [
|
| 790 |
{
|
| 791 |
"file": "index.html",
|
| 792 |
"data": code
|
| 793 |
+
},
|
| 794 |
+
{
|
| 795 |
+
"file": "package.json",
|
| 796 |
+
"data": json.dumps(package_json)
|
| 797 |
}
|
| 798 |
]
|
| 799 |
|
| 800 |
+
# ํ๋ก์ ํธ ์ค์
|
| 801 |
project_settings = {
|
|
|
|
|
|
|
| 802 |
"buildCommand": None,
|
| 803 |
"outputDirectory": ".",
|
| 804 |
+
"framework": "create-react-app" # create-react-app์ผ๋ก ๋ณ๊ฒฝ
|
|
|
|
| 805 |
}
|
| 806 |
|
| 807 |
# ๋ฐฐํฌ ์์ฒญ ๋ฐ์ดํฐ
|
|
|
|
| 810 |
"files": files,
|
| 811 |
"target": "production",
|
| 812 |
"projectSettings": project_settings,
|
| 813 |
+
"framework": "create-react-app"
|
| 814 |
}
|
| 815 |
|
| 816 |
deploy_response = requests.post(deploy_url, headers=headers, json=deploy_data)
|
|
|
|
| 818 |
if deploy_response.status_code != 200:
|
| 819 |
return f"๋ฐฐํฌ ์คํจ: {deploy_response.text}"
|
| 820 |
|
| 821 |
+
# ์๋ต์์ ์ค์ URL ๊ฐ์ ธ์ค๊ธฐ
|
| 822 |
+
response_data = deploy_response.json()
|
| 823 |
+
deployment_url = response_data.get('url', f"https://{project_name}.vercel.app")
|
| 824 |
|
| 825 |
+
# ๋ฐฐํฌ ์ํ ํ์ธ์ ์ํ ๋๊ธฐ
|
| 826 |
+
time.sleep(5) # ๋ฐฐํฌ๊ฐ ์๋ฃ๋ ๋๊น์ง ์ ์ ๋๊ธฐ
|
| 827 |
+
|
| 828 |
+
return f"""๋ฐฐํฌ ์๋ฃ! <a href="https://{deployment_url}" target="_blank" style="color: #1890ff; text-decoration: underline; cursor: pointer;">์ฌ๊ธฐ๋ฅผ ํด๋ฆญํ์ฌ ์ด๊ธฐ</a>"""
|
| 829 |
|
| 830 |
except Exception as e:
|
| 831 |
return f"๋ฐฐํฌ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
|