KalanaPabasara commited on
Commit ·
86328d1
1
Parent(s): 929c04b
Fix Streamlit secrets import compatibility
Browse files
app.py
CHANGED
|
@@ -14,7 +14,6 @@ from __future__ import annotations
|
|
| 14 |
import os
|
| 15 |
|
| 16 |
import streamlit as st
|
| 17 |
-
from streamlit.errors import StreamlitSecretNotFoundError
|
| 18 |
|
| 19 |
from feedback_store import FeedbackStore, format_feedback_error
|
| 20 |
from sincode_model import BeamSearchDecoder, SentenceTransliterator
|
|
@@ -25,9 +24,12 @@ st.set_page_config(page_title="සිංCode", page_icon="🇱🇰", layout="cen
|
|
| 25 |
|
| 26 |
def _secret_or_env(name: str, default: str = "") -> str:
|
| 27 |
try:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
pass
|
| 32 |
return os.getenv(name, default)
|
| 33 |
|
|
|
|
| 14 |
import os
|
| 15 |
|
| 16 |
import streamlit as st
|
|
|
|
| 17 |
|
| 18 |
from feedback_store import FeedbackStore, format_feedback_error
|
| 19 |
from sincode_model import BeamSearchDecoder, SentenceTransliterator
|
|
|
|
| 24 |
|
| 25 |
def _secret_or_env(name: str, default: str = "") -> str:
|
| 26 |
try:
|
| 27 |
+
value = st.secrets.get(name)
|
| 28 |
+
if value is not None:
|
| 29 |
+
return str(value)
|
| 30 |
+
except Exception:
|
| 31 |
+
# Compatible with Streamlit versions where secrets backend differs
|
| 32 |
+
# or no secrets file is configured.
|
| 33 |
pass
|
| 34 |
return os.getenv(name, default)
|
| 35 |
|