Spaces:
Runtime error
Runtime error
File size: 1,759 Bytes
5ee5085 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/bin/bash
# Run ClassLens locally (both backend and frontend)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "π Starting ClassLens locally..."
echo ""
# Check for .env file
if [ ! -f "../.env" ]; then
echo "β οΈ No .env file found. Please create one from env.example"
exit 1
fi
# Function to cleanup on exit
cleanup() {
echo ""
echo "π Stopping servers..."
pkill -f "uvicorn app.main" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM
# Start backend
echo "π¦ Starting backend on http://127.0.0.1:8000"
cd backend
if [ ! -d ".venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -q -e . > /dev/null 2>&1
# Load environment variables
export $(grep -v '^#' ../.env | xargs)
# Start backend in background
uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload > /tmp/classlens-backend.log 2>&1 &
BACKEND_PID=$!
# Wait a bit for backend to start
sleep 2
# Start frontend
echo "π¨ Starting frontend on http://localhost:3000"
cd ../frontend
# Install frontend dependencies if needed
if [ ! -d "node_modules" ]; then
echo "Installing frontend dependencies..."
npm install
fi
# Start frontend
npm run dev > /tmp/classlens-frontend.log 2>&1 &
FRONTEND_PID=$!
echo ""
echo "β
ClassLens is running!"
echo ""
echo " Backend: http://127.0.0.1:8000"
echo " Frontend: http://localhost:3000"
echo ""
echo " Backend logs: tail -f /tmp/classlens-backend.log"
echo " Frontend logs: tail -f /tmp/classlens-frontend.log"
echo ""
echo "Press Ctrl+C to stop both servers"
echo ""
# Wait for both processes
wait $BACKEND_PID $FRONTEND_PID
|