Download database.py from Rupesx007/uupload: direct link, hf CLI and curl.
- Browser
- Download file 739 Bytes
-
https://huggingface.co/spaces/Rupesx007/uupload/resolve/main/database.py
- Command line
-
hf download hf://spaces/Rupesx007/uupload/database.py
-
curl -L -o database.py https://huggingface.co/spaces/Rupesx007/uupload/resolve/main/database.py
739 Bytes
| import firebase_admin | |
| from firebase_admin import credentials, firestore | |
| def init_firebase(): | |
| """Initialize Firebase Admin SDK if not already initialized.""" | |
| try: | |
| # Check if Firebase app is already initialized | |
| if not firebase_admin._apps: | |
| # Load Firebase credentials | |
| cred = credentials.Certificate("cd.json") | |
| firebase_admin.initialize_app(cred) | |
| print("Firebase initialized successfully!") | |
| else: | |
| print("Firebase already initialized.") | |
| # Return Firestore client | |
| return firestore.client() | |
| except Exception as e: | |
| print(f"Error initializing Firebase: {e}") | |
| raise | |
| # Initialize Firestore | |
| db = init_firebase() |