Spaces:
Running
Running
Update app.py
Browse files188 unmodified lines18919019119219219319419511 unmodified lines20720820921021021121219 unmodified lines23223323423623523623723867 unmodified lines3063073083103093103113123133163143153163173 unmodified lines321322323326327324325326327328329330331332188 unmodified lines except Exception as e: return input_text, f'<div id="prompter_output_div">์ค๋ฅ: {e}</div>', "์ค๋ฅ", "์ค๋ฅ", input_text, input_text
# =========================================================# ์ฌ์ ๊ด๋ฆฌ API (๋๋ฝ๋์๋ ํจ์ ํฌํจ ๋ณต๊ตฌ ์๋ฃ!)# ์ฌ์ ๊ด๋ฆฌ API# =========================================================def validate_word(w): w = (w or "").strip()11 unmodified linesdef app_json(j): dict_store.save_pairs([[k, v] for i in json.loads(j)["items"] for k, v in (i.items() if isinstance(json.loads(j)["items"], dict) else [i])], True); return "ํ๋ฌ์ค ์๋ฃ!"def over_json(j): dict_store.save_pairs([[k, v] for i in json.loads(j)["items"] for k, v in (i.items() if isinstance(json.loads(j)["items"], dict) else [i])], False); return "๋ฎ์ด์ฐ๊ธฐ ์๋ฃ!"
# โ
๋๋ฝ๋์๋ 2๊ฐ์ง ํต์ฌ ํจ์ ๋ณต๊ตฌdef get_file(): return dict_path if os.path.exists(dict_path) else None
19 unmodified linesjs_copy = "(t) => { if(t){ navigator.clipboard.writeText(t); alert('๋ณต์ฌ ์๋ฃ!'); } }"
# =========================================================# UI ๊ตฌ์ฑ (์๋ฌ์๋ ์ปค์คํ
๋ก๊ทธ์ธ ํฌํจ)# UI ๊ตฌ์ฑ# =========================================================with gr.Blocks(theme="default", css=custom_css) as iface: gr.Markdown("## ๐๏ธ ๋๋ง์ TTS ์ ์ฒ๋ฆฌ ๋ณํ๊ธฐ")67 unmodified lines btn_ap.click(app_json, json_in, j_stat) btn_ov.click(over_json, json_in, j_stat) # โ
๋๋ฝ๋์๋ ์
๋ก๋ UI ๋ณต๊ตฌ up_file = gr.File(label="๋ฐฑ์
ํ์ผ ์
๋ก๋") up_stat = gr.Textbox(label="์ํ") up_file.upload(upload_file, up_file, up_stat)
# --------------------------------------------------------- # 3. ๋ก๊ทธ์ธ ์ฒ๋ฆฌ ๋ก์ง # 3. ๋ก๊ทธ์ธ ์ฒ๋ฆฌ ๋ก์ง (๋์๋ฌธ์ ๋ฌด์ ๊ธฐ๋ฅ ์ถ๊ฐ) # --------------------------------------------------------- def check_login(user_id, user_pw): secret_str = os.getenv("AUTH_USERS")3 unmodified lines try: users_dict = json.loads(secret_str) except: pass if users_dict.get(user_id) == user_pw: is_admin = (user_id == "a") # ๋ชจ๋ ์์ด๋๋ฅผ ์๋ฌธ์๋ก ๋ณํํด์ ๋น๊ต lower_users_dict = {k.lower(): v for k, v in users_dict.items()} input_id_lower = (user_id or "").lower() if lower_users_dict.get(input_id_lower) == user_pw: is_admin = (input_id_lower == "a") return gr.update(visible=False), gr.update(visible=True), "โ
๋ก๊ทธ์ธ ์ฑ๊ณต!", gr.update(visible=is_admin) else: return gr.update(visible=True), gr.update(visible=False), "โ ์์ด๋ ๋๋ ๋น๋ฐ๋ฒํธ๊ฐ ํ๋ ธ์ต๋๋ค.", gr.update(visible=False)app.py+9-7