syncmaster5 / app_config.py
aseelflihan's picture
Initial commit without node_modules
88fbdc0
"""
Configuration Module for SyncMaster
إعدادات التطبيق الأساسية
"""
import os
import logging
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
class AppConfig:
"""Configuration class for SyncMaster application"""
# Server settings
STREAMLIT_PORT = int(os.getenv('STREAMLIT_PORT', 5050))
RECORDER_PORT = int(os.getenv('RECORDER_PORT', 5001))
# Development vs Production
IS_PRODUCTION = os.getenv('SPACE_ID') is not None or os.getenv('RAILWAY_ENVIRONMENT') is not None
# Host settings
if IS_PRODUCTION:
STREAMLIT_HOST = "0.0.0.0"
RECORDER_HOST = "0.0.0.0"
else:
STREAMLIT_HOST = "localhost"
RECORDER_HOST = "localhost"
# Integration settings
USE_INTEGRATED_SERVER = IS_PRODUCTION or os.getenv('USE_INTEGRATED_SERVER', 'true').lower() == 'true'
# Logging
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
@classmethod
def get_streamlit_url(cls):
"""Get the Streamlit application URL"""
return f"http://{cls.STREAMLIT_HOST}:{cls.STREAMLIT_PORT}"
@classmethod
def get_recorder_url(cls):
"""Get the recorder server URL"""
return f"http://{cls.RECORDER_HOST}:{cls.RECORDER_PORT}"
@classmethod
def log_config(cls):
"""Log current configuration"""
logging.info("📋 SyncMaster Configuration:")
logging.info(f" • Production Mode: {cls.IS_PRODUCTION}")
logging.info(f" • Integrated Server: {cls.USE_INTEGRATED_SERVER}")
logging.info(f" • Streamlit: {cls.get_streamlit_url()}")
logging.info(f" • Recorder: {cls.get_recorder_url()}")
# Initialize configuration
config = AppConfig()
if __name__ == "__main__":
config.log_config()