import os import logging from dotenv import load_dotenv logger = logging.getLogger(__name__) # Load environment variables from .env file if it exists load_dotenv() def get_config(): """ Load configuration from environment variables """ config = { # Database connection 'DATABASE_URL': os.getenv('DATABASE_URL', 'postgresql://postgres:postgres@localhost:5432/postgres'), # Server settings 'HOST': os.getenv('HOST', '0.0.0.0'), 'PORT': os.getenv('PORT', '7860'), 'SHARE': os.getenv('SHARE', 'false').lower() == 'true', # Logging 'LOG_LEVEL': os.getenv('LOG_LEVEL', 'INFO') } # Set logging level logging.basicConfig(level=getattr(logging, config['LOG_LEVEL'])) return config