Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
94 lines (75 loc) · 3.43 KB
/
Copy pathconfig.py
File metadata and controls
94 lines (75 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# ===============================================================================
# Développeur: Jonathan Kakesa | Date: 19/12/2024 | Heure: 18:55
# Description: Configuration centralisée pour ULC-ICAM Turnin System
# Fonctionnalités: Paramètres app, email, uploads, sécurité, environnements
# Nouvelles: Support compression, rapports, téléchargement lot
# ===============================================================================
import os
from dotenv import load_dotenv
# Chargement des variables d'environnement
load_dotenv()
class Config:
"""Configuration principale de l'application ULC-ICAM"""
# Configuration Flask de base
SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'ulc-icam-secret-key-2024'
DEBUG = os.environ.get('FLASK_ENV') == 'development'
# Configuration des clés API
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY')
GOOGLE_SEARCH_ENGINE_ID = os.environ.get('GOOGLE_SEARCH_ENGINE_ID')
HUGGINGFACE_API_KEY = os.environ.get('HUGGINGFACE_API_KEY')
# Configuration des uploads
UPLOAD_FOLDER = os.environ.get('UPLOAD_FOLDER', 'uploads')
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB maximum
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'docx', 'doc', 'py', 'java', 'cpp', 'c'}
# Configuration de la correction automatique
AUTO_CORRECTION_ENABLED = True
CORRECTION_TIMEOUT = 30 # secondes
# Configuration de la détection de plagiat
PLAGIARISM_THRESHOLD = 30.0 # Pourcentage de similarité
PLAGIARISM_ENABLED = True
# Configuration de sécurité
SESSION_TIMEOUT = 3600 # 1 heure
MAX_LOGIN_ATTEMPTS = 5
# Configuration des données
DATA_FILE = 'data.json'
BACKUP_ENABLED = True
# Configuration email pour notifications
MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.gmail.com')
MAIL_PORT = int(os.environ.get('MAIL_PORT', '587'))
MAIL_USE_TLS = True
MAIL_USE_SSL = False
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER', 'noreply@ulc-icam.cd')
# Configuration des notifications
NOTIFICATIONS_ENABLED = os.environ.get('NOTIFICATIONS_ENABLED', 'true').lower() == 'true'
NOTIFICATION_TYPES = {
'new_assignment': True,
'grades_published': True,
'assignment_reminder': True
}
@classmethod
def validate(cls):
"""Valide la configuration et retourne les avertissements"""
warnings = []
if cls.SECRET_KEY == 'ulc-icam-secret-key-2024':
warnings.append("⚠️ Changez la clé secrète en production")
if not os.path.exists(cls.UPLOAD_FOLDER):
warnings.append(f"📁 Dossier {cls.UPLOAD_FOLDER} sera créé")
return warnings
# Configuration pour différents environnements
class DevelopmentConfig(Config):
"""Configuration pour le développement"""
DEBUG = True
class ProductionConfig(Config):
"""Configuration pour la production"""
DEBUG = False
SECRET_KEY = os.environ.get('FLASK_SECRET_KEY') or 'CHANGE-ME-IN-PRODUCTION'
# Sélection automatique de la configuration
def get_config():
"""Retourne la configuration selon l'environnement"""
env = os.environ.get('FLASK_ENV', 'development')
if env == 'production':
return ProductionConfig
return DevelopmentConfig