Spaces:
Sleeping
Sleeping
| import os | |
| import secrets | |
| from typing import Optional | |
| class Settings: | |
| def __init__(self): | |
| # Generate a secure API key if not provided | |
| self.api_key: str = os.getenv("API_KEY", secrets.token_urlsafe(32)) | |
| # Generate a separate admin key for sensitive operations | |
| self.admin_key: str = os.getenv("ADMIN_KEY", secrets.token_urlsafe(32)) | |
| self.ollama_host: str = os.getenv("OLLAMA_HOST", "127.0.0.1:11434") | |
| self.app_host: str = os.getenv("APP_HOST", "0.0.0.0") | |
| self.app_port: int = int(os.getenv("APP_PORT", "7860")) | |
| # Print both keys for easy access | |
| print("=" * 60) | |
| print("π AUTHENTICATION KEYS") | |
| print("=" * 60) | |
| print(f"π API Key (for regular usage): {self.api_key}") | |
| print(f"π§ Admin Key (for key management): {self.admin_key}") | |
| print("=" * 60) | |
| print("π¨ SAVE BOTH KEYS SECURELY!") | |
| print("π API Key: Use for all model operations") | |
| print("π§ Admin Key: Use for key management and admin operations") | |
| print("=" * 60) | |
| settings = Settings() |