cjber commited on
Commit
623395d
·
1 Parent(s): 3379fd6

fix: add credentials if the .secrets.toml doesn't exist

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import polars as pl
2
  import py7zr
3
  import streamlit as st
@@ -9,14 +12,25 @@ from planning_ai.preprocessing.azure_doc import azure_process_pdfs
9
  from planning_ai.preprocessing.gcpt3 import main as preprocess_main
10
 
11
  # Load authentication secrets
12
- auth = st.secrets.to_dict()
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Initialize the authenticator
15
  authenticator = stauth.Authenticate(
16
  auth["credentials"],
17
- auth["cookie"]["name"],
18
- auth["cookie"]["key"],
19
- auth["cookie"]["expiry_days"],
20
  )
21
 
22
  UPLOAD_DIR = Paths.RAW / "gcpt3"
 
1
+ from os import getenv
2
+ from pathlib import Path
3
+
4
  import polars as pl
5
  import py7zr
6
  import streamlit as st
 
12
  from planning_ai.preprocessing.gcpt3 import main as preprocess_main
13
 
14
  # Load authentication secrets
15
+ if Path(".streamlit/secrets.toml").exists():
16
+ auth = st.secrets.to_dict()
17
+ else:
18
+ auth = {}
19
+ auth["credentials"] = {
20
+ "usernames": {
21
+ "admin": {
22
+ "email": getenv("EMAIL"),
23
+ "password": getenv("PASSWORD"),
24
+ }
25
+ }
26
+ }
27
 
28
  # Initialize the authenticator
29
  authenticator = stauth.Authenticate(
30
  auth["credentials"],
31
+ # auth["cookie"]["name"],
32
+ # auth["cookie"]["key"],
33
+ # auth["cookie"]["expiry_days"],
34
  )
35
 
36
  UPLOAD_DIR = Paths.RAW / "gcpt3"