Spaces:
Sleeping
Sleeping
Download config.py from archittmittal/Email-Segregation: direct link, hf CLI and curl.
- Browser
- Download file 862 Bytes
-
https://huggingface.co/spaces/archittmittal/Email-Segregation/resolve/main/config.py
- Command line
-
hf download hf://spaces/archittmittal/Email-Segregation/config.py
-
curl -L -o config.py https://huggingface.co/spaces/archittmittal/Email-Segregation/resolve/main/config.py
862 Bytes
| import os | |
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | |
| # Check if we are running in a Hugging Face Space with persistent storage mounted at /data | |
| if os.path.exists('/data') and os.access('/data', os.W_OK): | |
| DATA_DIR = '/data' | |
| print(f"[ShipSeg] Using Hugging Face persistent storage volume at: {DATA_DIR}") | |
| else: | |
| DATA_DIR = os.path.join(BASE_DIR, 'data') | |
| print(f"[ShipSeg] Using local directory for storage: {DATA_DIR}") | |
| os.makedirs(DATA_DIR, exist_ok=True) | |
| raw_db_url = os.environ.get('DATABASE_URL') | |
| if raw_db_url: | |
| # SQLAlchemy 1.4+ requires postgresql:// instead of legacy postgres:// | |
| if raw_db_url.startswith("postgres://"): | |
| DATABASE_URL = raw_db_url.replace("postgres://", "postgresql://", 1) | |
| else: | |
| DATABASE_URL = raw_db_url | |
| else: | |
| DATABASE_URL = f'sqlite:///{os.path.join(DATA_DIR, "emails.db")}' | |