Skip to content

Commit

Permalink
Update medapp.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudhendra committed Oct 17, 2024
1 parent e68584b commit 3f7d889
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions medapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ def get_firebase_key():
For local development, returns the path from FIREBASE_KEY_PATH.
"""
logging.info("Attempting to retrieve Firebase key...")
logging.info(f"Available secrets: {', '.join(st.secrets.keys())}")

# Check if FIREBASE_KEY_JSON exists in Streamlit secrets
if 'FIREBASE_KEY_JSON' in st.secrets:
logging.info("Found FIREBASE_KEY_JSON in secrets")
firebase_key_json = st.secrets['FIREBASE_KEY_JSON']
if 'FIREBASE_KEY_JSON' in st.secrets or 'firebase_key_json' in st.secrets:
firebase_key_json = st.secrets.get('FIREBASE_KEY_JSON') or st.secrets.get('firebase_key_json')
logging.info(f"First 20 characters of FIREBASE_KEY_JSON: {firebase_key_json[:20]}...")

try:
# Try to parse it as JSON
json.loads(firebase_key_json)
logging.info("Successfully parsed FIREBASE_KEY_JSON as JSON")
return firebase_key_json # Return the JSON string directly
return firebase_key_json
except json.JSONDecodeError:
logging.info("FIREBASE_KEY_JSON is not valid JSON, treating as file path")
# If it's not valid JSON, treat it as a file path
if os.path.exists(firebase_key_json):
return firebase_key_json
logging.info("FIREBASE_KEY_JSON is not valid JSON")

# For local development, use FIREBASE_KEY_PATH from environment variables
firebase_key_path = os.getenv("FIREBASE_KEY_PATH")
Expand Down

0 comments on commit 3f7d889

Please sign in to comment.