refact: phase 1
This commit is contained in:
22
app.py
22
app.py
@@ -3,8 +3,10 @@ import logging
|
||||
from flask import Flask, render_template
|
||||
from models import db, Assessment, Student, ClassGroup
|
||||
from commands import init_db
|
||||
from config import config
|
||||
from app_config_classes import config
|
||||
from app_config import config_manager
|
||||
from exceptions.handlers import register_error_handlers
|
||||
from core.logging import setup_logging
|
||||
|
||||
# Import blueprints
|
||||
from routes.assessments import bp as assessments_bp
|
||||
@@ -22,23 +24,15 @@ def create_app(config_name=None):
|
||||
# Initialiser la configuration de l'application
|
||||
app.app_config = config_manager
|
||||
|
||||
# Configuration du logging
|
||||
if not app.debug and not app.testing:
|
||||
if not os.path.exists('logs'):
|
||||
os.mkdir('logs')
|
||||
|
||||
file_handler = logging.FileHandler('logs/school_management.log')
|
||||
file_handler.setFormatter(logging.Formatter(
|
||||
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
|
||||
))
|
||||
file_handler.setLevel(logging.INFO)
|
||||
app.logger.addHandler(file_handler)
|
||||
app.logger.setLevel(logging.INFO)
|
||||
app.logger.info('Application de gestion scolaire démarrée')
|
||||
# Configuration du logging structuré
|
||||
setup_logging(app)
|
||||
|
||||
# Initialize extensions
|
||||
db.init_app(app)
|
||||
|
||||
# Register error handlers
|
||||
register_error_handlers(app)
|
||||
|
||||
# Initialiser la configuration par défaut après l'initialisation de la DB
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
Reference in New Issue
Block a user