Spaces:
Running
Running
Ig0tU commited on
Commit ·
849592b
1
Parent(s): 1025312
fix: explicit environment variable loading for HF secrets
Browse files
main.py
CHANGED
|
@@ -19,24 +19,31 @@ async def health():
|
|
| 19 |
return {"status": "ok", "message": "Weatherhack API is live"}
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
| 22 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 23 |
|
| 24 |
|
| 25 |
class Settings(BaseSettings):
|
| 26 |
-
weatherstack_access_key: str = "test"
|
| 27 |
|
| 28 |
model_config = SettingsConfigDict(
|
| 29 |
env_file=".env",
|
| 30 |
extra="ignore",
|
| 31 |
-
env_prefix="", # Ensure it picks up bare env vars
|
| 32 |
)
|
| 33 |
|
| 34 |
|
| 35 |
settings = Settings()
|
| 36 |
|
| 37 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
print(
|
| 39 |
-
f"DEBUG:
|
| 40 |
)
|
| 41 |
|
| 42 |
|
|
|
|
| 19 |
return {"status": "ok", "message": "Weatherhack API is live"}
|
| 20 |
|
| 21 |
|
| 22 |
+
import os
|
| 23 |
+
from pydantic import Field
|
| 24 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
| 25 |
|
| 26 |
|
| 27 |
class Settings(BaseSettings):
|
| 28 |
+
weatherstack_access_key: str = Field("test", alias="WEATHERSTACK_ACCESS_KEY")
|
| 29 |
|
| 30 |
model_config = SettingsConfigDict(
|
| 31 |
env_file=".env",
|
| 32 |
extra="ignore",
|
|
|
|
| 33 |
)
|
| 34 |
|
| 35 |
|
| 36 |
settings = Settings()
|
| 37 |
|
| 38 |
+
# Full debug for HF environment
|
| 39 |
+
if "WEATHERSTACK_ACCESS_KEY" in os.environ:
|
| 40 |
+
env_val = os.environ["WEATHERSTACK_ACCESS_KEY"]
|
| 41 |
+
print(f"DEBUG: Found in os.environ. Length: {len(env_val)}")
|
| 42 |
+
else:
|
| 43 |
+
print("DEBUG: NOT found in os.environ")
|
| 44 |
+
|
| 45 |
print(
|
| 46 |
+
f"DEBUG: Settings value: {settings.weatherstack_access_key[:4]}...{settings.weatherstack_access_key[-4:]}"
|
| 47 |
)
|
| 48 |
|
| 49 |
|