# from flask import Flask # from flask_sqlalchemy import SQLAlchemy # from flask_migrate import Migrate # from flask_login import LoginManager # from flask_ldap3_login import LDAP3LoginManager # import os # db = SQLAlchemy() # migrate = Migrate() # login_manager = LoginManager() # ldap_manager = LDAP3LoginManager() # from app.models import User # # Flask-Login user loader # @login_manager.user_loader # def load_user(user_id): # return User.query.get(int(user_id)) # def create_app(): # app = Flask(__name__) # # -------------------- # # App config # # -------------------- # app.config['SECRET_KEY'] = 'dev-secret-key' # 🔐 change this in production # app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:admin@localhost/excel_data7' # # 🔽 Add upload folder config # app.config['UPLOAD_FOLDER'] = os.path.join(app.root_path, 'upload') # # Make sure folder exists # os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) # # -------------------- # # LDAP config # # -------------------- # app.config['LDAP_HOST'] = 'openldap' # app.config['LDAP_PORT'] = 389 # app.config['LDAP_BASE_DN'] = 'dc=lcepl,dc=org' # app.config['LDAP_BIND_USER_DN'] = 'cn=admin,dc=lcepl,dc=org' # app.config['LDAP_BIND_USER_PASSWORD'] = 'admin123' # app.config['LDAP_USER_DN'] = 'ou=users' # app.config['LDAP_GROUP_DN'] = 'ou=groups' # app.config['LDAP_USER_RDN_ATTR'] = 'uid' # app.config['LDAP_USER_LOGIN_ATTR'] = 'uid' # # Extra to avoid BasicAuth popup # app.config['USE_LDAP_AUTH'] = True # app.config['LDAP_REQUIRE_CERT'] = False # app.config['LDAP_LOGIN_VIEW'] = 'main.login' # your login route # # -------------------- # # Init extensions # # -------------------- # db.init_app(app) # migrate.init_app(app, db) # login_manager.init_app(app) # ldap_manager.init_app(app) # # Redirect to login if not authenticated # login_manager.login_view = "main.login" # # -------------------- # # Register blueprints # # -------------------- # from app.routes.main import main # app.register_blueprint(main) # return app