Files
capitalism-eats-the-world/app/__init__.py
elpatron 27e185c2a6 Fix Markov simulation chart display issue
- Fix circular import issue by moving simulation_manager to app/__init__.py
- Enhance get_wealth_evolution to include inequality metrics data
- Add get_inequality_evolution method for complete chart data
- Update API to return top10_shares and capital_shares in evolution data
- Modify onSimulationComplete to fetch and populate charts with complete data
- Fix simulation threading to properly mark completion state
- Add test script to verify chart data generation

The charts now properly display simulation results by fetching complete
evolution data when simulation completes, resolving the empty diagrams issue.
2025-08-24 19:44:24 +02:00

43 lines
1.0 KiB
Python

"""
Flask Application Factory
Creates and configures the Flask application with SocketIO support for real-time
updates of the Markov economics simulation.
"""
from flask import Flask
from flask_socketio import SocketIO
from config import config
from app.models import SimulationManager
# Initialize SocketIO
socketio = SocketIO(cors_allowed_origins="*")
# Global simulation manager instance
simulation_manager = SimulationManager()
def create_app(config_name='development'):
"""
Create and configure the Flask application.
Args:
config_name: Configuration profile to use
Returns:
Configured Flask application instance
"""
app = Flask(__name__)
app.config.from_object(config[config_name])
# Initialize extensions
socketio.init_app(app, async_mode='threading')
# Register blueprints
from .routes.main import main_bp
from .routes.api import api_bp
app.register_blueprint(main_bp)
app.register_blueprint(api_bp, url_prefix='/api')
return app