Kimty commited on
Commit
5d6a96a
·
1 Parent(s): 1e5ecc5

refactor: update authentication mechanism for Gradio app launch

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -4,10 +4,12 @@ import gradio as gr
4
  from core import RAG, parse_cas_input
5
 
6
  rag = RAG()
7
-
8
- DEMO_USER = os.getenv("USERNAME", "demo")
9
- DEMO_PASS = os.getenv("PASSWORD", "chemical2026")
10
-
 
 
11
  EXAMPLE_INPUTS = [
12
  "7664-39-3",
13
  "7664-39-3, 128-37-0",
@@ -127,4 +129,4 @@ with gr.Blocks(
127
  )
128
 
129
  if __name__ == "__main__":
130
- demo.launch(auth=(DEMO_USER, DEMO_PASS))
 
4
  from core import RAG, parse_cas_input
5
 
6
  rag = RAG()
7
+ auth_list = []
8
+ auth_env = os.getenv("AUTH_USERS", "")
9
+ for pair in auth_env.split(","):
10
+ if ":" in pair:
11
+ user, pwd = pair.split(":", 1)
12
+ auth_list.append((user.strip(), pwd.strip()))
13
  EXAMPLE_INPUTS = [
14
  "7664-39-3",
15
  "7664-39-3, 128-37-0",
 
129
  )
130
 
131
  if __name__ == "__main__":
132
+ demo.launch(auth=auth_list)