Spaces:
Sleeping
Sleeping
Download services/supabase_client.py from mozoj4/sentio-backend: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/spaces/mozoj4/sentio-backend/resolve/cb6601bdaec7e77fe09d38bc94de1f3e35ccafba/services/supabase_client.py
- Command line
-
hf download hf://spaces/mozoj4/sentio-backend@cb6601bdaec7e77fe09d38bc94de1f3e35ccafba/services/supabase_client.py
-
curl -L -o supabase_client.py https://huggingface.co/spaces/mozoj4/sentio-backend/resolve/cb6601bdaec7e77fe09d38bc94de1f3e35ccafba/services/supabase_client.py
673 Bytes
| import os | |
| from supabase import create_client, Client | |
| _client: Client | None = None | |
| def get_supabase() -> Client: | |
| """Return a singleton Supabase client. | |
| Uses the service-role key so that server-side operations can bypass | |
| Row Level Security where needed. Never expose this key to the frontend. | |
| """ | |
| global _client | |
| if _client is None: | |
| url = os.getenv("SUPABASE_URL") | |
| key = os.getenv("SUPABASE_SERVICE_KEY") | |
| if not url or not key: | |
| raise RuntimeError( | |
| "SUPABASE_URL and SUPABASE_SERVICE_KEY must be set in the environment" | |
| ) | |
| _client = create_client(url, key) | |
| return _client | |