Spaces:
Sleeping
Sleeping
Download backend/database.py from afsheenadaf/perception-backend: direct link, hf CLI and curl.
- Browser
- Download file 389 Bytes
-
https://huggingface.co/spaces/afsheenadaf/perception-backend/resolve/main/backend/database.py
- Command line
-
hf download hf://spaces/afsheenadaf/perception-backend/backend/database.py
-
curl -L -o database.py https://huggingface.co/spaces/afsheenadaf/perception-backend/resolve/main/backend/database.py
389 Bytes
| import os | |
| import json | |
| import firebase_admin | |
| from firebase_admin import credentials, firestore | |
| def get_db(): | |
| if not firebase_admin._apps: | |
| firebase_config = json.loads( | |
| os.environ["FIREBASE_CREDENTIALS_JSON"] | |
| ) | |
| cred = credentials.Certificate(firebase_config) | |
| firebase_admin.initialize_app(cred) | |
| return firestore.client() | |
| db = get_db() |