"""
Production Server Script for Windows
Uses Waitress WSGI server - production-ready for Windows
"""
import os
import sys
from waitress import serve

# Set production environment
os.environ['FLASK_MODE'] = 'production'

# Import Flask app
from app import app

if __name__ == '__main__':
    # Production configuration
    host = '0.0.0.0'  # Listen on all interfaces
    port = 5000       # Port (change if needed)
    threads = 6       # Number of threads (good for 6 users)
    
    print("=" * 60)
    print("🚀 Starting Sales Dashboard in PRODUCTION mode")
    print("=" * 60)
    print(f"Host: {host}")
    print(f"Port: {port}")
    print(f"Threads: {threads}")
    print(f"Mode: {os.environ.get('FLASK_MODE', 'development')}")
    print("=" * 60)
    print("Server is running. Press Ctrl+C to stop.")
    print("=" * 60)
    
    # Start production server
    serve(
        app,
        host=host,
        port=port,
        threads=threads,
        url_scheme='https',  # Tells Flask we're behind HTTPS proxy
        _quiet=False
    )
