-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from theakash04/dev/akash
- Loading branch information
Showing
3 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
__pycache__ | ||
.venv | ||
notebook.ipynb | ||
.snow | ||
.snow | ||
.devcontainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import os | ||
import streamlit as st | ||
from dotenv import load_dotenv | ||
|
||
def get_secret(key: str): | ||
"""Fetch secret from Streamlit secrets or fallback to environment variables.""" | ||
secrets_file_path = os.path.join(os.getcwd(), ".streamlit", "secrets.toml") | ||
if not os.path.exists(secrets_file_path): | ||
return os.environ[key] | ||
# Use st.secrets only if the file exists and the key is present | ||
"""Fetch secret from environment variables or fallback to Streamlit secrets.""" | ||
secret_value = os.environ[key] | ||
if secret_value: | ||
return secret_value | ||
|
||
# if not found in env | ||
try: | ||
if key in st.secrets: | ||
return st.secrets[key] | ||
except FileNotFoundError: | ||
pass # Silently skip st.secrets if secrets.toml doesn't exist | ||
pass | ||
|
||
return None | ||
|
||
|
||
|
||
__all__ = ["get_secret"] |