Spaces:
Sleeping
Sleeping
Update app1.py
Browse files
app1.py
CHANGED
|
@@ -26,11 +26,18 @@ st.markdown(
|
|
| 26 |
unsafe_allow_html=True
|
| 27 |
)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Google Sheets connection
|
| 30 |
@st.cache_data(ttl=300) # Cache for 5 minutes (same as refresh interval)
|
| 31 |
def load_data():
|
| 32 |
scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
|
| 33 |
-
creds =
|
| 34 |
client = gspread.authorize(creds)
|
| 35 |
|
| 36 |
sheet_id = '1J4YQEf8WvdlS3BjIOya0jsrPHolBEVodSAmhYF9XtSk'
|
|
|
|
| 26 |
unsafe_allow_html=True
|
| 27 |
)
|
| 28 |
|
| 29 |
+
def get_creds():
|
| 30 |
+
raw = os.getenv("GCP_SERVICE_ACCOUNT")
|
| 31 |
+
if raw is None:
|
| 32 |
+
raise ValueError("Missing GCP_CREDENTIALS environment variable.")
|
| 33 |
+
return Credentials.from_service_account_info(json.loads(raw), scopes=SCOPES)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
# Google Sheets connection
|
| 37 |
@st.cache_data(ttl=300) # Cache for 5 minutes (same as refresh interval)
|
| 38 |
def load_data():
|
| 39 |
scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
|
| 40 |
+
creds = get_creds()
|
| 41 |
client = gspread.authorize(creds)
|
| 42 |
|
| 43 |
sheet_id = '1J4YQEf8WvdlS3BjIOya0jsrPHolBEVodSAmhYF9XtSk'
|