Spaces:
Runtime error
Runtime error
Download src/api/supabase_client.py from BattleFiven/ai-tester-platform: direct link, hf CLI and curl.
- Browser
- Download file 751 Bytes
-
https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/src/api/supabase_client.py
- Command line
-
hf download hf://spaces/BattleFiven/ai-tester-platform/src/api/supabase_client.py
-
curl -L -o supabase_client.py https://huggingface.co/spaces/BattleFiven/ai-tester-platform/resolve/main/src/api/supabase_client.py
751 Bytes
| """Supabase client initialization""" | |
| import os | |
| from supabase import Client, create_client | |
| def get_supabase_client() -> Client: | |
| """Get Supabase client instance""" | |
| supabase_url = os.getenv("SUPABASE_URL") | |
| supabase_key = os.getenv("SUPABASE_SERVICE_KEY") or os.getenv("SUPABASE_ANON_KEY") | |
| if not supabase_url or not supabase_key: | |
| raise ValueError("Supabase credentials not configured. Check your .env file.") | |
| return create_client(supabase_url, supabase_key) | |
| # Global client instance | |
| _supabase_client = None | |
| def get_db() -> Client: | |
| """Get or create Supabase client""" | |
| global _supabase_client | |
| if _supabase_client is None: | |
| _supabase_client = get_supabase_client() | |
| return _supabase_client | |