#!/bin/bash

# Ensure we are in the script directory
cd "$(dirname "$0")"

# Check if virtual environment exists
if [ ! -d "venv" ]; then
    echo "Creating virtual environment..."
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
else
    source venv/bin/activate
fi

echo "Starting NecroHash WebGUI..."
# Run with gunicorn for production or python directly for dev.
# Using python for simplicity as requested on Pi 1
# Use authbind if available to bind port 80 as non-root
if command -v authbind >/dev/null 2>&1; then
    authbind --deep python app.py
else
    python app.py
fi
