import os from datetime import timedelta class Config: """Configuration de base""" SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(32) SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///school_management.db' SQLALCHEMY_TRACK_MODIFICATIONS = False WTF_CSRF_TIME_LIMIT = timedelta(hours=1) class DevelopmentConfig(Config): """Configuration pour le développement""" DEBUG = True SQLALCHEMY_ECHO = os.environ.get('DB_ECHO', 'False').lower() == 'true' class ProductionConfig(Config): """Configuration pour la production""" DEBUG = False SQLALCHEMY_ECHO = False @classmethod def init_app(cls, app): Config.init_app(app) # Log vers stderr en production import logging from logging import StreamHandler file_handler = StreamHandler() file_handler.setLevel(logging.WARNING) app.logger.addHandler(file_handler) class TestingConfig(Config): """Configuration pour les tests""" TESTING = True SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:' WTF_CSRF_ENABLED = False DEBUG = True config = { 'development': DevelopmentConfig, 'production': ProductionConfig, 'testing': TestingConfig, 'default': DevelopmentConfig }