Spaces:
Running
Running
Update app.py
Browse files309 unmodified lines310311312313314313314315316317318319320321321322322323324325326327324325326328329330331332328333334335336337332338339334335336337338340341342343344345309 unmodified lines 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") users_dict = {"a": "1", "User1": "1111"} sys_status = "๊ธฐ๋ณธ ์์๊ณ์ ์๋ ์ค (a/1 ๋๋ User1/1111)" if secret_str: try: users_dict = json.loads(secret_str) except: pass try: users_dict = json.loads(secret_str) sys_status = "ํ๊น
ํ์ด์ค ์ํฌ๋ฆฟ ์ ์ ์ฐ๊ฒฐ๋จ" except Exception as e: sys_status = f"๐จ ํ๊น
ํ์ด์ค ์ํฌ๋ฆฟ JSON ์์ฑ ์๋ฌ (๋ฐ์ดํ๋ ์ผํ ํ์ธ ์๋ง): {e}" # ๋ชจ๋ ์์ด๋๋ฅผ ์๋ฌธ์๋ก ๋ณํํด์ ๋น๊ต lower_users_dict = {k.lower(): v for k, v in users_dict.items()} input_id_lower = (user_id or "").lower() # ๊ณต๋ฐฑ ์ ๊ฑฐ ๋ฐ ์๋ฌธ์ ๋ณํ lower_users_dict = {str(k).strip().lower(): str(v).strip() for k, v in users_dict.items()} input_id_lower = str(user_id or "").strip().lower() input_pw = str(user_pw or "").strip() if lower_users_dict.get(input_id_lower) == user_pw: if lower_users_dict.get(input_id_lower) == input_pw: is_admin = (input_id_lower == "a") return gr.update(visible=False), gr.update(visible=True), "โ
๋ก๊ทธ์ธ ์ฑ๊ณต!", gr.update(visible=is_admin) else: err_msg = f"โ ์ ์ ์คํจ.\n[์
๋ ฅํ ์์ด๋]: '{input_id_lower}'\n[ํ์ฌ ์์คํ
์ํ]: {sys_status}" return gr.update(visible=True), gr.update(visible=False), "โ ์์ด๋ ๋๋ ๋น๋ฐ๋ฒํธ๊ฐ ํ๋ ธ์ต๋๋ค.", gr.update(visible=False) return gr.update(visible=True), gr.update(visible=False), err_msg, gr.update(visible=False)
btn_login.click( fn=check_login, inputs=[in_id, in_pw], outputs=[login_view, main_view, login_msg, admin_acc] ) # ๋ฒํผ ํด๋ฆญ ๋ฐ ์ํฐํค ์น๋ฉด ๋ฐ๋ก ๋ก๊ทธ์ธ ๋๋๋ก ์ค์ btn_login.click(fn=check_login, inputs=[in_id, in_pw], outputs=[login_view, main_view, login_msg, admin_acc]) in_pw.submit(fn=check_login, inputs=[in_id, in_pw], outputs=[login_view, main_view, login_msg, admin_acc])
iface.load(None, js=js_sync)
app.py+18-14