"""ContentForge — Flask app factory.""" import os from flask import Flask from flask_wtf.csrf import CSRFProtect _csrf = CSRFProtect() def create_app(): app = Flask(__name__, template_folder="templates") app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "dev-contentforge-2026") app.config["MAX_CONTENT_LENGTH"] = 30 * 1024 * 1024 _csrf.init_app(app) from app.home.routes import bp as home_bp app.register_blueprint(home_bp) from app.tools.content_repurposer.routes import bp as content_repurposer_bp app.register_blueprint(content_repurposer_bp, url_prefix='/content-repurposer') from app.tools.ai_debate_arena.routes import bp as ai_debate_arena_bp app.register_blueprint(ai_debate_arena_bp, url_prefix='/ai-debate-arena') from flask import jsonify @app.errorhandler(Exception) def _handle_exc(e): code = getattr(e, "code", 500) return jsonify({"error": str(e)}), code return app