Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,266 +1,571 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from pathlib import Path
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
from
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
if
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
if not hf_token
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
def _deploy_space(repo_url, hf_token, private):
|
| 48 |
-
"""๊ณตํต ๋ฐฐํฌ ๋ก์ง"""
|
| 49 |
-
# URL ์ ๋ฆฌ
|
| 50 |
repo_url = repo_url.strip()
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
return """### โ ์๋ชป๋ Repository URL
|
| 55 |
|
| 56 |
-
GitHub URL
|
| 57 |
-
|
| 58 |
|
| 59 |
-
#
|
| 60 |
try:
|
| 61 |
-
|
| 62 |
-
return f"""### โ
Space
|
| 63 |
|
| 64 |
๐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์์ต๋๋ค!
|
| 65 |
|
| 66 |
-
**Space URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
---
|
| 69 |
-
|
|
|
|
| 70 |
except Exception as e:
|
| 71 |
error_msg = str(e)
|
| 72 |
|
| 73 |
-
#
|
| 74 |
if "BAPI_TOKEN" in error_msg:
|
| 75 |
return """### โ Brave Search API ํ ํฐ ํ์
|
| 76 |
|
| 77 |
-
|
| 78 |
-
[Brave Search API](https://brave.com/search/api/)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
elif "FRIENDLI_TOKEN" in error_msg:
|
| 80 |
return """### โ Friendli AI ํ ํฐ ํ์
|
| 81 |
|
| 82 |
-
|
| 83 |
-
[Friendli AI](https://friendli.ai/)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
elif "401" in error_msg or "403" in error_msg:
|
| 90 |
return """### โ ์ธ์ฆ ์คํจ
|
| 91 |
|
| 92 |
-
|
| 93 |
-
https://huggingface.co/settings/tokens
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
else:
|
| 95 |
return f"""### โ ๋ฐฐํฌ ์ค๋ฅ
|
| 96 |
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
| 103 |
|
| 104 |
-
# Gradio
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
#
|
| 162 |
-
deploy_btn.click(
|
| 163 |
-
fn=launch_deploy_oauth,
|
| 164 |
-
inputs=[repo_input, private_checkbox],
|
| 165 |
-
outputs=output_status
|
| 166 |
-
).then(
|
| 167 |
-
fn=lambda: gr.update(visible=True),
|
| 168 |
-
outputs=output_status
|
| 169 |
-
)
|
| 170 |
-
else:
|
| 171 |
-
# ์๋ ํ ํฐ ์
๋ ฅ ๋ฒ์
|
| 172 |
gr.Markdown("""
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
| 177 |
""")
|
| 178 |
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
private_checkbox = gr.Checkbox(
|
| 195 |
-
label="๐ Private Space๋ก ์์ฑ",
|
| 196 |
-
value=False,
|
| 197 |
-
info="์ฒดํฌํ๋ฉด ๋น๊ณต๊ฐ Space๋ก ์์ฑ๋ฉ๋๋ค"
|
| 198 |
-
)
|
| 199 |
|
|
|
|
| 200 |
deploy_btn = gr.Button(
|
| 201 |
-
"๐
|
| 202 |
variant="primary",
|
| 203 |
size="lg"
|
| 204 |
)
|
| 205 |
|
|
|
|
| 206 |
output_status = gr.Markdown(
|
| 207 |
elem_classes="status-box",
|
| 208 |
visible=False
|
| 209 |
)
|
| 210 |
|
| 211 |
-
#
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
)
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
-
|
| 240 |
-
missing_vars = []
|
| 241 |
-
if not os.getenv("BAPI_TOKEN"):
|
| 242 |
-
missing_vars.append("BAPI_TOKEN (Brave Search API)")
|
| 243 |
-
if not os.getenv("FRIENDLI_TOKEN"):
|
| 244 |
-
missing_vars.append("FRIENDLI_TOKEN (Friendli AI)")
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
else:
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
HF Space Auto-Deployer
|
| 4 |
+
----------------------
|
| 5 |
+
๊ณต๊ฐ Git ๋ ํฌ์งํ ๋ฆฌ๋ฅผ Hugging Face Gradio Space๋ก ์๋ ๋ณํ ๋ฐ ๋ฐฐํฌํฉ๋๋ค.
|
| 6 |
+
|
| 7 |
+
ํ์ ํ๊ฒฝ๋ณ์:
|
| 8 |
+
- BAPI_TOKEN: Brave Search API Key
|
| 9 |
+
- FRIENDLI_TOKEN: Friendli AI API Token
|
| 10 |
+
- HF_TOKEN (์ ํ): ๊ธฐ๋ณธ HuggingFace ํ ํฐ
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
import os
|
| 14 |
import sys
|
| 15 |
+
import json
|
| 16 |
+
import argparse
|
| 17 |
+
import subprocess
|
| 18 |
+
import tempfile
|
| 19 |
+
import textwrap
|
| 20 |
+
import requests
|
| 21 |
+
import shutil
|
| 22 |
from pathlib import Path
|
| 23 |
+
from typing import Optional, Dict, List
|
| 24 |
|
| 25 |
+
import gradio as gr
|
| 26 |
+
import git
|
| 27 |
+
from huggingface_hub import HfApi, login
|
| 28 |
|
| 29 |
+
# ========== Brave Search ํฌํผ ========== #
|
| 30 |
+
def brave_search_repo(repo_url: str, count: int = 5) -> List[Dict]:
|
| 31 |
+
"""Brave Search API๋ก ๋ ํฌ์งํ ๋ฆฌ ๋ฉํ๋ฐ์ดํฐ ์์ง"""
|
| 32 |
+
api_key = os.getenv("BAPI_TOKEN")
|
| 33 |
+
if not api_key:
|
| 34 |
+
raise RuntimeError("ํ๊ฒฝ๋ณ์ BAPI_TOKEN์ด ์ค์ ๋์ด ์์ง ์์ต๋๋ค.")
|
| 35 |
+
|
| 36 |
+
headers = {"X-Subscription-Token": api_key, "Accept": "application/json"}
|
| 37 |
+
params = {"q": f'site:github.com "{repo_url}"', "count": count, "search_lang": "en"}
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
resp = requests.get(
|
| 41 |
+
"https://api.search.brave.com/res/v1/web/search",
|
| 42 |
+
headers=headers,
|
| 43 |
+
params=params,
|
| 44 |
+
timeout=10
|
| 45 |
+
)
|
| 46 |
+
resp.raise_for_status()
|
| 47 |
+
return resp.json().get("web", {}).get("results", [])
|
| 48 |
+
except Exception as e:
|
| 49 |
+
print(f"โ ๏ธ Brave Search ๊ฒฝ๊ณ : {e}")
|
| 50 |
+
return []
|
| 51 |
|
| 52 |
+
# ========== Friendli LLM ํฌํผ ========== #
|
| 53 |
+
def friendli_generate_scaffold(context: str) -> Dict:
|
| 54 |
+
"""Friendli AI๋ก app.py ๋ฐ requirements.txt ์๋ ์์ฑ"""
|
| 55 |
+
token = os.getenv("FRIENDLI_TOKEN")
|
| 56 |
+
if not token:
|
| 57 |
+
raise RuntimeError("ํ๊ฒฝ๋ณ์ FRIENDLI_TOKEN์ด ์ค์ ๋์ด ์์ง ์์ต๋๋ค.")
|
| 58 |
+
|
| 59 |
+
payload = {
|
| 60 |
+
"model": "meta-llama-3.1-70b-instruct",
|
| 61 |
+
"messages": [
|
| 62 |
+
{
|
| 63 |
+
"role": "system",
|
| 64 |
+
"content": textwrap.dedent("""
|
| 65 |
+
You are an expert Hugging Face Space architect. Given repository context,
|
| 66 |
+
generate a Gradio app that showcases the repository's functionality.
|
| 67 |
+
|
| 68 |
+
Output a JSON with these keys:
|
| 69 |
+
- app_py: Complete Gradio app code
|
| 70 |
+
- requirements_txt: Required Python packages
|
| 71 |
+
- need_docker: Boolean for Docker requirement
|
| 72 |
+
- dockerfile: Dockerfile content (if need_docker is true)
|
| 73 |
+
- summary: Brief description of the generated app
|
| 74 |
+
|
| 75 |
+
Important guidelines:
|
| 76 |
+
1. Always use Gradio for the interface
|
| 77 |
+
2. Make the app functional and user-friendly
|
| 78 |
+
3. Include proper error handling
|
| 79 |
+
4. Add clear instructions in the interface
|
| 80 |
+
5. Use appropriate Gradio components for the task
|
| 81 |
+
""")
|
| 82 |
+
},
|
| 83 |
+
{"role": "user", "content": context}
|
| 84 |
+
],
|
| 85 |
+
"max_tokens": 16384,
|
| 86 |
+
"temperature": 0.7,
|
| 87 |
+
"top_p": 0.9,
|
| 88 |
+
"stream": False
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
headers = {
|
| 92 |
+
"Authorization": f"Bearer {token}",
|
| 93 |
+
"Content-Type": "application/json"
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
try:
|
| 97 |
+
r = requests.post(
|
| 98 |
+
"https://api.friendli.ai/serverless/v1/chat/completions",
|
| 99 |
+
json=payload,
|
| 100 |
+
headers=headers,
|
| 101 |
+
timeout=120
|
| 102 |
+
)
|
| 103 |
+
r.raise_for_status()
|
| 104 |
+
|
| 105 |
+
# JSON ์๋ต ํ์ฑ
|
| 106 |
+
response_text = r.json()["choices"][0]["message"]["content"]
|
| 107 |
|
| 108 |
+
# JSON ๋ธ๋ก ์ถ์ถ (```json ... ``` ํ์ ์ฒ๋ฆฌ)
|
| 109 |
+
if "```json" in response_text:
|
| 110 |
+
start = response_text.find("```json") + 7
|
| 111 |
+
end = response_text.find("```", start)
|
| 112 |
+
response_text = response_text[start:end].strip()
|
| 113 |
+
|
| 114 |
+
return json.loads(response_text)
|
| 115 |
+
except json.JSONDecodeError as e:
|
| 116 |
+
print(f"โ ๏ธ JSON ํ์ฑ ์ค๋ฅ: {e}")
|
| 117 |
+
# ๊ธฐ๋ณธ Gradio ์ฑ ๋ฐํ
|
| 118 |
+
return {
|
| 119 |
+
"app_py": textwrap.dedent("""
|
| 120 |
+
import gradio as gr
|
| 121 |
+
|
| 122 |
+
def main():
|
| 123 |
+
return "This is an auto-generated Gradio app. Please customize it based on your repository."
|
| 124 |
+
|
| 125 |
+
demo = gr.Interface(
|
| 126 |
+
fn=main,
|
| 127 |
+
inputs=None,
|
| 128 |
+
outputs="text",
|
| 129 |
+
title="Auto-Generated Space",
|
| 130 |
+
description="This Space was automatically created. Please update app.py to add your functionality."
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
if __name__ == "__main__":
|
| 134 |
+
demo.launch()
|
| 135 |
+
"""),
|
| 136 |
+
"requirements_txt": "gradio>=4.0.0",
|
| 137 |
+
"need_docker": False,
|
| 138 |
+
"summary": "Basic Gradio template - please customize based on your repository"
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
# ========== ๋ฉ์ธ ๋ฐฐํฌ ๋ก์ง ========== #
|
| 142 |
+
def deploy(repo_url: str, hf_token: str, private: bool = False, hardware: Optional[str] = None) -> str:
|
| 143 |
+
"""๋ ํฌ์งํ ๋ฆฌ๋ฅผ Gradio Space๋ก ๋ฐฐํฌํ๊ณ Space URL ๋ฐํ"""
|
| 144 |
+
# HF ๋ก๊ทธ์ธ
|
| 145 |
+
login(hf_token)
|
| 146 |
+
api = HfApi(token=hf_token)
|
| 147 |
+
|
| 148 |
+
# ์ฌ์ฉ์ ์ ๋ณด ๋ฐ Space ์ด๋ฆ ์์ฑ
|
| 149 |
+
user = api.whoami()["name"]
|
| 150 |
+
repo_name = Path(repo_url.rstrip("/")).name.lower()
|
| 151 |
+
repo_name = repo_name.replace(".", "-").replace("_", "-")
|
| 152 |
+
space_id = f"{user}/{repo_name}-space"
|
| 153 |
+
|
| 154 |
+
print(f"๐ฆ Space ID: {space_id}")
|
| 155 |
|
| 156 |
+
# Space ์์ฑ
|
| 157 |
+
api.create_repo(
|
| 158 |
+
repo_id=space_id,
|
| 159 |
+
repo_type="space",
|
| 160 |
+
space_sdk="gradio",
|
| 161 |
+
private=private,
|
| 162 |
+
exist_ok=True
|
| 163 |
+
)
|
| 164 |
|
| 165 |
+
# Hardware ์ค์ (ํ์ํ ๊ฒฝ์ฐ)
|
| 166 |
+
if hardware:
|
| 167 |
+
try:
|
| 168 |
+
api.request_space_hardware(repo_id=space_id, hardware=hardware)
|
| 169 |
+
print(f"๐ฅ๏ธ Hardware ์ค์ : {hardware}")
|
| 170 |
+
except Exception as e:
|
| 171 |
+
print(f"โ ๏ธ Hardware ์ค์ ์คํจ: {e}")
|
| 172 |
|
| 173 |
+
with tempfile.TemporaryDirectory() as work_dir:
|
| 174 |
+
# 1) Brave Search๋ก ๋ฉํ๋ฐ์ดํฐ ์์ง
|
| 175 |
+
print("๐ ๋ ํฌ์งํ ๋ฆฌ ์ ๋ณด ์์ง ์ค...")
|
| 176 |
+
brave_meta = brave_search_repo(repo_url)
|
| 177 |
+
|
| 178 |
+
# 2) ์๋ณธ ๋ ํฌ์งํ ๋ฆฌ ํด๋ก
|
| 179 |
+
print("๐ฅ ๋ ํฌ์งํ ๋ฆฌ ํด๋ก ์ค...")
|
| 180 |
+
src_path = Path(work_dir) / "source"
|
| 181 |
+
git.Repo.clone_from(repo_url, src_path, depth=1)
|
| 182 |
+
|
| 183 |
+
# README ์ฝ๊ธฐ
|
| 184 |
+
readme_content = ""
|
| 185 |
+
readme_path = src_path / "README.md"
|
| 186 |
+
if readme_path.exists():
|
| 187 |
+
readme_content = readme_path.read_text(encoding="utf-8", errors="ignore")[:4000]
|
| 188 |
+
|
| 189 |
+
# ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ ํ์
|
| 190 |
+
tree_output = subprocess.run(
|
| 191 |
+
["bash", "-c", f"find {src_path} -type f -name '*.py' -o -name '*.md' -o -name '*.txt' -o -name '*.json' -o -name '*.yaml' -o -name '*.yml' | head -n 50"],
|
| 192 |
+
capture_output=True,
|
| 193 |
+
text=True
|
| 194 |
+
).stdout
|
| 195 |
+
|
| 196 |
+
# ์ปจํ
์คํธ ์์ฑ
|
| 197 |
+
context = textwrap.dedent(f"""
|
| 198 |
+
## Repository URL
|
| 199 |
+
{repo_url}
|
| 200 |
+
|
| 201 |
+
## Brave Search Metadata
|
| 202 |
+
{json.dumps(brave_meta, ensure_ascii=False, indent=2)}
|
| 203 |
+
|
| 204 |
+
## Repository Structure
|
| 205 |
+
{tree_output}
|
| 206 |
+
|
| 207 |
+
## README.md Content (first 4KB)
|
| 208 |
+
{readme_content}
|
| 209 |
+
|
| 210 |
+
Please create a Gradio app that best showcases this repository's functionality.
|
| 211 |
+
If it's a model, create an inference interface. If it's a dataset, create a viewer.
|
| 212 |
+
If it's a library, create a demo. Make it user-friendly and functional.
|
| 213 |
+
""")
|
| 214 |
+
|
| 215 |
+
# 3) Friendli AI๋ก ์ค์บํด๋ ์์ฑ
|
| 216 |
+
print("๐ค AI๋ก Gradio ์ฑ ์์ฑ ์ค...")
|
| 217 |
+
scaffold = friendli_generate_scaffold(context)
|
| 218 |
+
|
| 219 |
+
# 4) Space ๋ ํฌ์งํ ๋ฆฌ ํด๋ก ๋ฐ ํ์ผ ์์ฑ
|
| 220 |
+
print("๐ค Space์ ํ์ผ ์
๋ก๋ ์ค...")
|
| 221 |
+
dst_path = Path(work_dir) / "space"
|
| 222 |
+
|
| 223 |
+
# HTTPS URL with token for authentication
|
| 224 |
+
space_url = f"https://{hf_token}@huggingface.co/spaces/{space_id}"
|
| 225 |
+
space_repo = git.Repo.clone_from(space_url, dst_path, depth=1)
|
| 226 |
+
|
| 227 |
+
# ํ์ผ ์์ฑ
|
| 228 |
+
(dst_path / "app.py").write_text(scaffold["app_py"], encoding="utf-8")
|
| 229 |
+
(dst_path / "requirements.txt").write_text(scaffold["requirements_txt"], encoding="utf-8")
|
| 230 |
+
|
| 231 |
+
if scaffold.get("need_docker"):
|
| 232 |
+
(dst_path / "Dockerfile").write_text(scaffold["dockerfile"], encoding="utf-8")
|
| 233 |
+
|
| 234 |
+
# README.md ์์ฑ
|
| 235 |
+
readme_content = f"""---
|
| 236 |
+
title: {repo_name.replace("-", " ").title()}
|
| 237 |
+
emoji: ๐
|
| 238 |
+
colorFrom: blue
|
| 239 |
+
colorTo: purple
|
| 240 |
+
sdk: gradio
|
| 241 |
+
sdk_version: 4.44.1
|
| 242 |
+
app_file: app.py
|
| 243 |
+
pinned: false
|
| 244 |
+
---
|
| 245 |
|
| 246 |
+
# {repo_name.replace("-", " ").title()}
|
| 247 |
+
|
| 248 |
+
Automatically deployed from: {repo_url}
|
| 249 |
+
|
| 250 |
+
## Summary
|
| 251 |
+
{scaffold.get("summary", "Auto-generated Gradio Space")}
|
| 252 |
+
|
| 253 |
+
---
|
| 254 |
+
*Created by HF Space Auto-Deployer*
|
| 255 |
+
"""
|
| 256 |
+
(dst_path / "README.md").write_text(readme_content, encoding="utf-8")
|
| 257 |
+
|
| 258 |
+
# Git ์ปค๋ฐ ๋ฐ ํธ์
|
| 259 |
+
space_repo.index.add(["app.py", "requirements.txt", "README.md"])
|
| 260 |
+
if scaffold.get("need_docker"):
|
| 261 |
+
space_repo.index.add(["Dockerfile"])
|
| 262 |
|
| 263 |
+
# Git ์ค์
|
| 264 |
+
space_repo.config_writer().set_value("user", "name", user).release()
|
| 265 |
+
space_repo.config_writer().set_value("user", "email", f"{user}@users.noreply.huggingface.co").release()
|
| 266 |
+
|
| 267 |
+
space_repo.index.commit("Initial auto-deployment")
|
| 268 |
+
|
| 269 |
+
# ํธ์
|
| 270 |
+
origin = space_repo.remote("origin")
|
| 271 |
+
origin.push()
|
| 272 |
+
|
| 273 |
+
return f"https://huggingface.co/spaces/{space_id}"
|
| 274 |
+
|
| 275 |
+
# ========== Gradio UI ========== #
|
| 276 |
+
def launch_deploy(repo_url: str, private: bool, request: gr.Request) -> str:
|
| 277 |
+
"""Gradio UI์์ ํธ์ถ๋๋ ๋ฐฐํฌ ํจ์"""
|
| 278 |
+
# ํ ํฐ ๊ฐ์ ธ์ค๊ธฐ (์ฐ์ ์์: Gradio ์ธ์ฆ โ ํ๊ฒฝ๋ณ์)
|
| 279 |
+
hf_token = None
|
| 280 |
|
| 281 |
+
# Gradio ์ธ์ฆ ํค๋ ํ์ธ
|
| 282 |
+
auth_header = request.headers.get("authorization")
|
| 283 |
+
if auth_header and auth_header.startswith("Bearer "):
|
| 284 |
+
hf_token = auth_header.split(" ")[1].strip()
|
| 285 |
|
| 286 |
+
# ํ๊ฒฝ๋ณ์ ํด๋ฐฑ
|
| 287 |
+
if not hf_token:
|
| 288 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 289 |
+
|
| 290 |
+
if not hf_token:
|
| 291 |
+
return """### โ ์ธ์ฆ ํ์
|
| 292 |
|
| 293 |
+
๋ค์ ์ค ํ๋์ ๋ฐฉ๋ฒ์ผ๋ก ์ธ์ฆํด์ฃผ์ธ์:
|
| 294 |
+
1. **์ฐ์ธก ์๋จ ํ๋กํ โ Sign in with Hugging Face**
|
| 295 |
+
2. **Space Settings โ Variables and secrets โ HF_TOKEN ์ค์ **"""
|
| 296 |
|
| 297 |
+
# URL ๊ฒ์ฆ
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
repo_url = repo_url.strip()
|
| 299 |
+
if not repo_url:
|
| 300 |
+
return "### โ Repository URL์ ์
๋ ฅํด์ฃผ์ธ์."
|
| 301 |
|
| 302 |
+
if not any(repo_url.startswith(prefix) for prefix in ["https://github.com/", "http://github.com/"]):
|
| 303 |
+
return """### โ ์๋ชป๋ URL ํ์
|
|
|
|
| 304 |
|
| 305 |
+
GitHub URL์ ์
๋ ฅํด์ฃผ์ธ์.
|
| 306 |
+
์: https://github.com/username/repository"""
|
| 307 |
|
| 308 |
+
# ๋ฐฐํฌ ์คํ
|
| 309 |
try:
|
| 310 |
+
space_url = deploy(repo_url, hf_token, private)
|
| 311 |
+
return f"""### โ
Space ๋ฐฐํฌ ์๋ฃ!
|
| 312 |
|
| 313 |
๐ ์ฑ๊ณต์ ์ผ๋ก ๋ฐฐํฌ๋์์ต๋๋ค!
|
| 314 |
|
| 315 |
+
**Space URL**: [{space_url}]({space_url})
|
| 316 |
+
|
| 317 |
+
**๋ค์ ๋จ๊ณ:**
|
| 318 |
+
1. Space ํ์ด์ง ๋ฐฉ๋ฌธ
|
| 319 |
+
2. ๋น๋ ๋ก๊ทธ ํ์ธ (์ฐ์ธก ์๋จ "Logs" ํญ)
|
| 320 |
+
3. ๋น๋ ์๋ฃ ๋๊ธฐ (๋ณดํต 2-5๋ถ)
|
| 321 |
+
4. ํ์์ app.py ์์
|
| 322 |
|
| 323 |
---
|
| 324 |
+
๐ก **ํ**: Space๊ฐ ์ ๋๋ก ์๋ํ์ง ์์ผ๋ฉด Files ํญ์์ app.py๋ฅผ ์ง์ ์์ ํ ์ ์์ต๋๋ค."""
|
| 325 |
+
|
| 326 |
except Exception as e:
|
| 327 |
error_msg = str(e)
|
| 328 |
|
| 329 |
+
# ์์ธํ ์ค๋ฅ ์๋ด
|
| 330 |
if "BAPI_TOKEN" in error_msg:
|
| 331 |
return """### โ Brave Search API ํ ํฐ ํ์
|
| 332 |
|
| 333 |
+
**์ค์ ๋ฐฉ๋ฒ:**
|
| 334 |
+
1. [Brave Search API](https://brave.com/search/api/) ๊ฐ์
|
| 335 |
+
2. ๋ฌด๋ฃ API Key ๋ฐ๊ธ
|
| 336 |
+
3. **์ด Space์** Settings โ Variables and secrets
|
| 337 |
+
4. `BAPI_TOKEN` = `[๋ฐ๊ธ๋ฐ์ ํค]` ์ถ๊ฐ"""
|
| 338 |
+
|
| 339 |
elif "FRIENDLI_TOKEN" in error_msg:
|
| 340 |
return """### โ Friendli AI ํ ํฐ ํ์
|
| 341 |
|
| 342 |
+
**์ค์ ๋ฐฉ๋ฒ:**
|
| 343 |
+
1. [Friendli AI](https://friendli.ai/) ๊ฐ์
|
| 344 |
+
2. API Key ๋ฐ๊ธ
|
| 345 |
+
3. **์ด Space์** Settings โ Variables and secrets
|
| 346 |
+
4. `FRIENDLI_TOKEN` = `[๋ฐ๊ธ๋ฐ์ ํค]` ์ถ๊ฐ"""
|
| 347 |
+
|
| 348 |
+
elif "401" in error_msg or "403" in error_msg or "Unauthorized" in error_msg:
|
|
|
|
| 349 |
return """### โ ์ธ์ฆ ์คํจ
|
| 350 |
|
| 351 |
+
**ํด๊ฒฐ ๋ฐฉ๋ฒ:**
|
| 352 |
+
1. [ํ ํฐ ํ์ด์ง](https://huggingface.co/settings/tokens) ๋ฐฉ๋ฌธ
|
| 353 |
+
2. "New token" ํด๋ฆญ
|
| 354 |
+
3. **Write** ๊ถํ ์ฒดํฌ โ
|
| 355 |
+
4. Space Settings์์ HF_TOKEN ์
๋ฐ์ดํธ"""
|
| 356 |
+
|
| 357 |
else:
|
| 358 |
return f"""### โ ๋ฐฐํฌ ์ค๋ฅ
|
| 359 |
|
| 360 |
+
**์ค๋ฅ ๋ด์ฉ:**
|
| 361 |
+
```
|
| 362 |
+
{error_msg}
|
| 363 |
+
```
|
| 364 |
|
| 365 |
+
**์ผ๋ฐ์ ์ธ ํด๊ฒฐ ๋ฐฉ๋ฒ:**
|
| 366 |
+
1. Repository๊ฐ public์ธ์ง ํ์ธ
|
| 367 |
+
2. URL ํ์ ํ์ธ (https://github.com/user/repo)
|
| 368 |
+
3. ๋คํธ์ํฌ ์ฐ๊ฒฐ ํ์ธ
|
| 369 |
+
4. ์ ์ ํ ์ฌ์๋"""
|
| 370 |
|
| 371 |
+
# ========== Gradio App ========== #
|
| 372 |
+
def create_ui():
|
| 373 |
+
"""Gradio UI ์์ฑ"""
|
| 374 |
+
with gr.Blocks(
|
| 375 |
+
title="HF Space Auto-Deployer",
|
| 376 |
+
theme=gr.themes.Soft(),
|
| 377 |
+
css="""
|
| 378 |
+
.main-container {
|
| 379 |
+
max-width: 800px;
|
| 380 |
+
margin: 0 auto;
|
| 381 |
+
padding: 20px;
|
| 382 |
+
}
|
| 383 |
+
.header {
|
| 384 |
+
text-align: center;
|
| 385 |
+
margin-bottom: 30px;
|
| 386 |
+
padding: 20px;
|
| 387 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 388 |
+
color: white;
|
| 389 |
+
border-radius: 10px;
|
| 390 |
+
}
|
| 391 |
+
.header h1 {
|
| 392 |
+
margin: 0;
|
| 393 |
+
font-size: 2.5em;
|
| 394 |
+
}
|
| 395 |
+
.header p {
|
| 396 |
+
margin: 10px 0 0 0;
|
| 397 |
+
opacity: 0.9;
|
| 398 |
+
}
|
| 399 |
+
.gr-button-primary {
|
| 400 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 401 |
+
border: none !important;
|
| 402 |
+
font-size: 1.1em !important;
|
| 403 |
+
padding: 12px 30px !important;
|
| 404 |
+
}
|
| 405 |
+
.gr-button-primary:hover {
|
| 406 |
+
transform: translateY(-2px);
|
| 407 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
| 408 |
+
}
|
| 409 |
+
.status-box {
|
| 410 |
+
padding: 20px;
|
| 411 |
+
border-radius: 10px;
|
| 412 |
+
margin-top: 20px;
|
| 413 |
+
border: 1px solid #e0e0e0;
|
| 414 |
+
background-color: #f9f9f9;
|
| 415 |
+
}
|
| 416 |
+
.info-box {
|
| 417 |
+
background-color: #e3f2fd;
|
| 418 |
+
padding: 15px;
|
| 419 |
+
border-radius: 8px;
|
| 420 |
+
border-left: 4px solid #2196F3;
|
| 421 |
+
margin: 10px 0;
|
| 422 |
+
}
|
| 423 |
+
.examples-box {
|
| 424 |
+
background-color: #f3e5f5;
|
| 425 |
+
padding: 15px;
|
| 426 |
+
border-radius: 8px;
|
| 427 |
+
margin: 10px 0;
|
| 428 |
+
}
|
| 429 |
+
"""
|
| 430 |
+
) as demo:
|
| 431 |
+
with gr.Column(elem_classes="main-container"):
|
| 432 |
+
# ํค๋
|
| 433 |
+
gr.HTML("""
|
| 434 |
+
<div class="header">
|
| 435 |
+
<h1>๐ GitHub โ HuggingFace Space</h1>
|
| 436 |
+
<p>AI๊ฐ ๋น์ ์ GitHub ํ๋ก์ ํธ๋ฅผ Gradio ์ฑ์ผ๋ก ๋ณํํฉ๋๋ค</p>
|
| 437 |
+
</div>
|
| 438 |
+
""")
|
| 439 |
|
| 440 |
+
# ์ธ์ฆ ์๋ด
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
gr.Markdown("""
|
| 442 |
+
<div class="info-box">
|
| 443 |
+
<b>๐ ์ธ์ฆ ๋ฐฉ๋ฒ:</b><br>
|
| 444 |
+
โข <b>๋ฐฉ๋ฒ 1</b>: ์ฐ์ธก ์๋จ ํ๋กํ โ Sign in with Hugging Face<br>
|
| 445 |
+
โข <b>๋ฐฉ๋ฒ 2</b>: Space Settings์์ HF_TOKEN ํ๊ฒฝ๋ณ์ ์ค์
|
| 446 |
+
</div>
|
| 447 |
""")
|
| 448 |
|
| 449 |
+
# ์
๋ ฅ ํ๋
|
| 450 |
+
with gr.Group():
|
| 451 |
+
repo_input = gr.Textbox(
|
| 452 |
+
label="๐ฆ GitHub Repository URL",
|
| 453 |
+
placeholder="https://github.com/username/repository",
|
| 454 |
+
info="Public repository URL์ ์
๋ ฅํ์ธ์",
|
| 455 |
+
lines=1
|
| 456 |
+
)
|
| 457 |
+
|
| 458 |
+
private_checkbox = gr.Checkbox(
|
| 459 |
+
label="๐ Private Space๋ก ์์ฑ",
|
| 460 |
+
value=False,
|
| 461 |
+
info="์ฒดํฌํ๋ฉด ๋ณธ์ธ๋ง ์ ๊ทผ ๊ฐ๋ฅํ Space๊ฐ ์์ฑ๋ฉ๋๋ค"
|
| 462 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
|
| 464 |
+
# ๋ฐฐํฌ ๋ฒํผ
|
| 465 |
deploy_btn = gr.Button(
|
| 466 |
+
"๐ Space ์์ฑํ๊ธฐ",
|
| 467 |
variant="primary",
|
| 468 |
size="lg"
|
| 469 |
)
|
| 470 |
|
| 471 |
+
# ์ํ ์ถ๋ ฅ
|
| 472 |
output_status = gr.Markdown(
|
| 473 |
elem_classes="status-box",
|
| 474 |
visible=False
|
| 475 |
)
|
| 476 |
|
| 477 |
+
# ์์
|
| 478 |
+
gr.HTML("""
|
| 479 |
+
<div class="examples-box">
|
| 480 |
+
<b>๐ก ์์ ํ๋ก์ ํธ:</b><br>
|
| 481 |
+
โข <code>https://github.com/gradio-app/gradio/tree/main/demo/hello_world</code><br>
|
| 482 |
+
โข <code>https://github.com/huggingface/transformers</code><br>
|
| 483 |
+
โข <code>https://github.com/CompVis/stable-diffusion</code>
|
| 484 |
+
</div>
|
| 485 |
+
""")
|
| 486 |
+
|
| 487 |
+
# ์ฌ์ฉ ๊ฐ์ด๋
|
| 488 |
+
with gr.Accordion("๐ ์ฌ์ฉ ๊ฐ์ด๋", open=False):
|
| 489 |
+
gr.Markdown("""
|
| 490 |
+
### ์๋ ์๋ฆฌ
|
| 491 |
+
1. **๐ ๋ถ์**: Brave Search๋ก ๋ ํฌ์งํ ๋ฆฌ ์ ๋ณด ์์ง
|
| 492 |
+
2. **๐ค ์์ฑ**: Friendli AI๊ฐ ๋ง์ถคํ Gradio ์ฑ ์ฝ๋ ์์ฑ
|
| 493 |
+
3. **๐ค ๋ฐฐํฌ**: HuggingFace Space์ ์๋ ์
๋ก๋ ๋ฐ ๋น๋
|
| 494 |
+
|
| 495 |
+
### ์ง์ํ๋ ํ๋ก์ ํธ ์ ํ
|
| 496 |
+
- โ
**ML ๋ชจ๋ธ**: ์ถ๋ก ์ธํฐํ์ด์ค ์๋ ์์ฑ
|
| 497 |
+
- โ
**๋ฐ์ดํฐ์
**: ๋ฐ์ดํฐ ํ์๊ธฐ ์์ฑ
|
| 498 |
+
- โ
**๋ผ์ด๋ธ๋ฌ๋ฆฌ**: ๋ฐ๋ชจ ์ฑ ์์ฑ
|
| 499 |
+
- โ
**์ผ๋ฐ ํ๋ก์ ํธ**: ๊ธฐ๋ฅ ์ผ์ผ์ด์ค ์์ฑ
|
| 500 |
+
|
| 501 |
+
### ํ์ํ API ํค
|
| 502 |
+
1. **BAPI_TOKEN**: [Brave Search API](https://brave.com/search/api/) (๋ฌด๋ฃ)
|
| 503 |
+
2. **FRIENDLI_TOKEN**: [Friendli AI](https://friendli.ai/) (๋ฌด๋ฃ ํฌ๋ ๋ง ์ ๊ณต)
|
| 504 |
+
|
| 505 |
+
### ๋ฌธ์ ํด๊ฒฐ
|
| 506 |
+
- **๋น๋ ์คํจ**: Space์ Logs ํญ ํ์ธ
|
| 507 |
+
- **์ฑ ์์ **: Files ํญ์์ app.py ์ง์ ํธ์ง
|
| 508 |
+
- **GPU ํ์**: Space Settings์์ Hardware ๋ณ๊ฒฝ
|
| 509 |
+
""")
|
| 510 |
|
| 511 |
+
# ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
| 512 |
+
deploy_btn.click(
|
| 513 |
+
fn=launch_deploy,
|
| 514 |
+
inputs=[repo_input, private_checkbox],
|
| 515 |
+
outputs=output_status
|
| 516 |
+
).then(
|
| 517 |
+
fn=lambda: gr.update(visible=True),
|
| 518 |
+
outputs=output_status
|
| 519 |
+
)
|
| 520 |
+
|
| 521 |
+
return demo
|
| 522 |
|
| 523 |
+
# ========== CLI ์ง์ ========== #
|
| 524 |
+
def main():
|
| 525 |
+
"""CLI ์คํ์ ์ํ ๋ฉ์ธ ํจ์"""
|
| 526 |
+
parser = argparse.ArgumentParser(description="Git ๋ ํฌ๋ฅผ Hugging Face Space๋ก ์๋ ๋ฐฐํฌ")
|
| 527 |
+
parser.add_argument("--repo_url", help="GitHub repository URL")
|
| 528 |
+
parser.add_argument("--hf_token", help="HuggingFace write token")
|
| 529 |
+
parser.add_argument("--private", action="store_true", help="Create private Space")
|
| 530 |
+
parser.add_argument("--hardware", help="GPU tier (e.g., 't4-medium')")
|
| 531 |
+
parser.add_argument("--no-ui", action="store_true", help="Run without Gradio UI")
|
| 532 |
|
| 533 |
+
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
|
| 535 |
+
# CLI ๋ชจ๋
|
| 536 |
+
if args.no_ui and args.repo_url and args.hf_token:
|
| 537 |
+
try:
|
| 538 |
+
url = deploy(args.repo_url, args.hf_token, args.private, args.hardware)
|
| 539 |
+
print(f"โ
๋ฐฐํฌ ์ฑ๊ณต: {url}")
|
| 540 |
+
except Exception as e:
|
| 541 |
+
print(f"โ ๋ฐฐํฌ ์คํจ: {e}", file=sys.stderr)
|
| 542 |
+
sys.exit(1)
|
| 543 |
+
# Gradio UI ๋ชจ๋
|
| 544 |
else:
|
| 545 |
+
# ํ๊ฒฝ ์ํ ์ถ๋ ฅ
|
| 546 |
+
print("\n" + "="*60)
|
| 547 |
+
print("๐ HF Space Auto-Deployer")
|
| 548 |
+
print("="*60)
|
| 549 |
+
|
| 550 |
+
# ํ๊ฒฝ๋ณ์ ์ฒดํฌ
|
| 551 |
+
env_checks = []
|
| 552 |
+
env_checks.append("โ
HF_TOKEN" if os.getenv("HF_TOKEN") else "โ ๏ธ HF_TOKEN (์ ํ์ฌํญ)")
|
| 553 |
+
env_checks.append("โ
BAPI_TOKEN" if os.getenv("BAPI_TOKEN") else "โ BAPI_TOKEN (ํ์)")
|
| 554 |
+
env_checks.append("โ
FRIENDLI_TOKEN" if os.getenv("FRIENDLI_TOKEN") else "โ FRIENDLI_TOKEN (ํ์)")
|
| 555 |
+
|
| 556 |
+
print("ํ๊ฒฝ๋ณ์ ์ํ:")
|
| 557 |
+
for check in env_checks:
|
| 558 |
+
print(f" {check}")
|
| 559 |
+
|
| 560 |
+
print("="*60 + "\n")
|
| 561 |
+
|
| 562 |
+
# Gradio ์ฑ ์คํ
|
| 563 |
+
demo = create_ui()
|
| 564 |
+
demo.launch(
|
| 565 |
+
share=False,
|
| 566 |
+
server_name="0.0.0.0",
|
| 567 |
+
server_port=7860
|
| 568 |
+
)
|
| 569 |
+
|
| 570 |
+
if __name__ == "__main__":
|
| 571 |
+
main()
|