Spaces:
Running
Running
Harikrishna Dev
commited on
Commit
·
09c97b4
1
Parent(s):
ae9c4df
Update app.py
Browse files
app.py
CHANGED
@@ -24,10 +24,17 @@ def is_valid_json(data):
|
|
24 |
except json.JSONDecodeError:
|
25 |
return False
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Function to initialize connection to Firebase Firestore
|
28 |
@st.cache_resource
|
29 |
def init_connection():
|
30 |
-
cred = credentials.Certificate(
|
31 |
firebase_admin.initialize_app(cred)
|
32 |
return firestore.client()
|
33 |
|
|
|
24 |
except json.JSONDecodeError:
|
25 |
return False
|
26 |
|
27 |
+
if "firebase_json_key" in os.environ:
|
28 |
+
firebase_json_key = os.getenv("firebase_json_key")
|
29 |
+
else:
|
30 |
+
firebase_json_key = st.secrets["firebase_json_key"]
|
31 |
+
|
32 |
+
firebase_credentials = json.loads(firebase_json_key)
|
33 |
+
|
34 |
# Function to initialize connection to Firebase Firestore
|
35 |
@st.cache_resource
|
36 |
def init_connection():
|
37 |
+
cred = credentials.Certificate(firebase_credentials)
|
38 |
firebase_admin.initialize_app(cred)
|
39 |
return firestore.client()
|
40 |
|