Spaces:
Runtime error
Runtime error
Commit
Β·
284a6d8
1
Parent(s):
41cdd3d
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,22 +107,36 @@ def generate_status(content_id):
|
|
| 107 |
url = API_HOME + END_STATUS
|
| 108 |
payload = {"id": content_id}
|
| 109 |
headers = set_header()
|
| 110 |
-
response = requests.request("POST", url, json=payload, headers=headers).json()
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
if response['
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
else:
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
|
| 128 |
def download_content(url):
|
|
|
|
| 107 |
url = API_HOME + END_STATUS
|
| 108 |
payload = {"id": content_id}
|
| 109 |
headers = set_header()
|
|
|
|
| 110 |
|
| 111 |
+
while True:
|
| 112 |
+
response = requests.request("POST", url, json=payload, headers=headers).json()
|
| 113 |
+
|
| 114 |
+
if response['success']:
|
| 115 |
+
if response['data']['status'] == 'queued' or response['data']['status'] == 'processing':
|
| 116 |
+
print('컨ν
μΈ μμ± μ€... μ μ ν λ€μ μλνμΈμ.')
|
| 117 |
+
time.sleep(10) # 10μ΄ λκΈ°
|
| 118 |
+
elif response['data']['status'] == 'success':
|
| 119 |
+
print('컨ν
μΈ μμ± μλ£!')
|
| 120 |
+
return response['data']['file']
|
| 121 |
+
else:
|
| 122 |
+
print(f"request μ€ν¨: {response}")
|
| 123 |
+
break
|
| 124 |
+
return 'FAILED'
|
| 125 |
|
| 126 |
+
def gradio_generate_status(content_id):
|
| 127 |
+
download_url = generate_status(content_id)
|
| 128 |
+
if download_url != 'FAILED':
|
| 129 |
+
return f"λ€μ΄λ‘λ λ§ν¬: {download_url}"
|
| 130 |
else:
|
| 131 |
+
return "컨ν
μΈ μμ± μ€ν¨ λλ IDκ° μλͺ»λμμ΅λλ€."
|
| 132 |
+
|
| 133 |
+
status_iface = gr.Interface(
|
| 134 |
+
fn=gradio_generate_status, # 컨ν
μΈ μν νμΈ λ° λ€μ΄λ‘λ λ§ν¬ μ 곡 ν¨μ
|
| 135 |
+
inputs=gr.Textbox(label="컨ν
μΈ ID"),
|
| 136 |
+
outputs=gr.Textbox(label="λ€μ΄λ‘λ λ§ν¬ λλ λ©μμ§")
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
status_iface.launch()
|
| 140 |
|
| 141 |
|
| 142 |
def download_content(url):
|