Update app.py
Browse files
app.py
CHANGED
@@ -940,7 +940,7 @@ def deploy_to_huggingface(code: str):
|
|
940 |
}
|
941 |
|
942 |
required_packages = set(['gradio==5.5.0']) # gradio๋ ๊ธฐ๋ณธ์ผ๋ก ํฌํจ
|
943 |
-
|
944 |
# ์ฝ๋์์ import ๋ฌธ ๋ถ์
|
945 |
import_pattern = r'^(?:from\s+(\S+)|import\s+([^,\s]+)(?:\s*,\s*([^,\s]+))*)'
|
946 |
|
@@ -949,9 +949,9 @@ def deploy_to_huggingface(code: str):
|
|
949 |
if line.startswith('import ') or line.startswith('from '):
|
950 |
matches = re.match(import_pattern, line)
|
951 |
if matches:
|
952 |
-
if matches.group(1):
|
953 |
package = matches.group(1).split('.')[0]
|
954 |
-
else:
|
955 |
packages = [p.strip() for p in re.findall(r'[\w.]+', line[7:])]
|
956 |
for package in packages:
|
957 |
package = package.split('.')[0]
|
@@ -959,8 +959,12 @@ def deploy_to_huggingface(code: str):
|
|
959 |
required_packages.add(import_mapping[package])
|
960 |
|
961 |
# 7) ์ ์ฒด ์ ํ๋ฆฌ์ผ์ด์
์ฝ๋ ์์ฑ
|
962 |
-
|
963 |
-
|
|
|
|
|
|
|
|
|
964 |
# 8) ํ์ผ ์์ฑ ๋ฐ ์
๋ก๋
|
965 |
with open("app.py", "w", encoding="utf-8") as f:
|
966 |
f.write(full_app_code)
|
@@ -985,6 +989,8 @@ def deploy_to_huggingface(code: str):
|
|
985 |
repo_type="space"
|
986 |
)
|
987 |
|
|
|
|
|
988 |
# 9) Rate Limit ์ ๋ณด ์
๋ฐ์ดํธ
|
989 |
deploy_count += 1
|
990 |
with open(rate_limit_file, 'w') as f:
|
|
|
940 |
}
|
941 |
|
942 |
required_packages = set(['gradio==5.5.0']) # gradio๋ ๊ธฐ๋ณธ์ผ๋ก ํฌํจ
|
943 |
+
|
944 |
# ์ฝ๋์์ import ๋ฌธ ๋ถ์
|
945 |
import_pattern = r'^(?:from\s+(\S+)|import\s+([^,\s]+)(?:\s*,\s*([^,\s]+))*)'
|
946 |
|
|
|
949 |
if line.startswith('import ') or line.startswith('from '):
|
950 |
matches = re.match(import_pattern, line)
|
951 |
if matches:
|
952 |
+
if matches.group(1):
|
953 |
package = matches.group(1).split('.')[0]
|
954 |
+
else:
|
955 |
packages = [p.strip() for p in re.findall(r'[\w.]+', line[7:])]
|
956 |
for package in packages:
|
957 |
package = package.split('.')[0]
|
|
|
959 |
required_packages.add(import_mapping[package])
|
960 |
|
961 |
# 7) ์ ์ฒด ์ ํ๋ฆฌ์ผ์ด์
์ฝ๋ ์์ฑ
|
962 |
+
# demo.launch() ํธ์ถ์ด ์๋์ง ํ์ธํ๊ณ ์์ผ๋ฉด ์ถ๊ฐ
|
963 |
+
if "demo.launch()" not in code:
|
964 |
+
full_app_code = code + "\n\nif __name__ == '__main__':\n demo.launch()"
|
965 |
+
else:
|
966 |
+
full_app_code = code
|
967 |
+
|
968 |
# 8) ํ์ผ ์์ฑ ๋ฐ ์
๋ก๋
|
969 |
with open("app.py", "w", encoding="utf-8") as f:
|
970 |
f.write(full_app_code)
|
|
|
989 |
repo_type="space"
|
990 |
)
|
991 |
|
992 |
+
|
993 |
+
|
994 |
# 9) Rate Limit ์ ๋ณด ์
๋ฐ์ดํธ
|
995 |
deploy_count += 1
|
996 |
with open(rate_limit_file, 'w') as f:
|