""" Flask dashboard for Pokemon Stock Monitor. Provides web UI for stats visualization and favorites management. """ import os import sys from pathlib import Path # Add parent directory to path for imports sys.path.insert(0, str(Path(__file__).parent.parent)) from flask import Flask, render_template, jsonify, request from flask_cors import CORS from src.database import get_database from src.favorites import get_favorites_manager # Handle both direct execution and package import try: from .api import api_bp except ImportError: from api import api_bp # Create Flask app app = Flask(__name__) CORS(app) # Register API blueprint app.register_blueprint(api_bp, url_prefix='/api') @app.route('/') def dashboard(): """Main dashboard page""" return render_template('index.html') @app.route('/products') def products_page(): """Products listing page""" return render_template('index.html', page='products') @app.route('/news') def news_page(): """News aggregation page""" return render_template('index.html', page='news') @app.route('/analytics') def analytics_page(): """Analytics page""" return render_template('index.html', page='analytics') @app.route('/favorites') def favorites_page(): """Favorites management page""" return render_template('index.html', page='favorites') @app.route('/settings') def settings_page(): """Settings page""" return render_template('index.html', page='settings') @app.route('/users') def users_page(): """Users management page""" return render_template('index.html', page='users') def run_dashboard(host: str = '0.0.0.0', port: int = 5000, debug: bool = False): """Run the dashboard server""" print(f"Starting Pokemon Stock Monitor Dashboard on http://{host}:{port}") app.run(host=host, port=port, debug=debug, threaded=True) if __name__ == '__main__': run_dashboard(debug=True)