Spaces:
Runtime error
Runtime error
Download api/dependencies.py from madhurithika22/Moulding: direct link, hf CLI and curl.
- Browser
- Download file 350 Bytes
-
https://huggingface.co/spaces/madhurithika22/Moulding/resolve/main/api/dependencies.py
- Command line
-
hf download hf://spaces/madhurithika22/Moulding/api/dependencies.py
-
curl -L -o dependencies.py https://huggingface.co/spaces/madhurithika22/Moulding/resolve/main/api/dependencies.py
350 Bytes
| from database.connection import db_client | |
| from core.config import settings | |
| async def get_db(): | |
| """Dependency to yield the active MongoDB instance or None if offline.""" | |
| if not db_client.client: | |
| return None | |
| try: | |
| # Return DB handle | |
| return db_client.client[settings.DB_NAME] | |
| except Exception: | |
| return None |