@echo off
REM Excel Filter Tool - Streamlit App Runner
REM This script starts the Streamlit web application

echo ========================================
echo   Excel Filter Tool - Web Application
echo ========================================
echo.

REM Check if Python is installed
python --version >nul 2>&1
if errorlevel 1 (
    echo Error: Python is not installed or not in PATH
    pause
    exit /b 1
)

REM Check if we're in the correct directory
if not exist "streamlit_app.py" (
    echo Error: streamlit_app.py not found
    echo Please run this script from the project root directory
    pause
    exit /b 1
)

REM Create virtual environment if it doesn't exist
if not exist "venv" (
    echo Creating virtual environment...
    python -m venv venv
)

REM Activate virtual environment
echo Activating virtual environment...
call venv\Scripts\activate.bat

REM Install/upgrade pip
echo Upgrading pip...
python -m pip install --upgrade pip -q

REM Install requirements
echo Installing dependencies...
pip install -r excel_filter\requirements.txt -q
pip install streamlit -q

echo.
echo Starting Streamlit server...
echo The app will open in your browser automatically.
echo Press Ctrl+C to stop the server.
echo.

REM Run Streamlit app
streamlit run streamlit_app.py

REM Deactivate virtual environment on exit
call venv\Scripts\deactivate.bat