Tesneem commited on
Commit
bb1806c
Β·
verified Β·
1 Parent(s): 6904829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -15,8 +15,28 @@ db_name = os.environ.get("MONGO_DB", "grant_docs")
15
  mongo_uri = f"mongodb+srv://{user}:{password}@{cluster}/{db_name}?retryWrites=true&w=majority&tls=true&tlsAllowInvalidCertificates=true"
16
  client = MongoClient(mongo_uri, tls=True, tlsAllowInvalidCertificates=True, serverSelectionTimeoutMS=20000)
17
  db = client[db_name]
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # === Streamlit UI ===
 
 
20
  st.set_page_config(page_title="Doc Chunker", layout="wide")
21
  st.title("πŸ“„ Document Chunker & Uploader")
22
 
 
15
  mongo_uri = f"mongodb+srv://{user}:{password}@{cluster}/{db_name}?retryWrites=true&w=majority&tls=true&tlsAllowInvalidCertificates=true"
16
  client = MongoClient(mongo_uri, tls=True, tlsAllowInvalidCertificates=True, serverSelectionTimeoutMS=20000)
17
  db = client[db_name]
18
+ def gate_ui():
19
+ APP_PASSWORD=st.secrets.get("APP_PASSWORD", os.getenv("APP_PASSWORD")).strip()
20
+ if "authed" not in st.session_state:
21
+ st.session_state.authed = False
22
+
23
+ if not APP_PASSWORD:
24
+ st.session_state.authed = True
25
+ return True
26
+ if st.session_state.authed:
27
+ return True
28
+ st.title("πŸ”’ Grant Buddy Login")
29
+ pwd=st.text_input("Enter password", type=password)
30
+ if st.button("Login"):
31
+ if pwd==APP_PASSWORD:
32
+ st.session_state.authed=True
33
+ st.rerun()
34
+ else:
35
+ st.error("Incorrect password.")
36
+ return False
37
  # === Streamlit UI ===
38
+ if not gate_ui():
39
+ return
40
  st.set_page_config(page_title="Doc Chunker", layout="wide")
41
  st.title("πŸ“„ Document Chunker & Uploader")
42