Files
2026-04-03 21:15:15 +07:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
echo "🔧 Lab4 Application Setup & Launch"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Check and create venv if not exists
if [ ! -d "venv" ]; then
echo "📦 Virtual environment not found. Creating venv..."
python3 -m venv venv
echo "✅ venv created"
else
echo "✅ venv already exists"
fi
# Activate venv
echo "🔄 Activating virtual environment..."
source venv/bin/activate
# Install/upgrade requirements
if [ -f "requirements.txt" ]; then
echo "📥 Installing dependencies from requirements.txt..."
pip install -q --upgrade pip
pip install -q -r requirements.txt
echo "✅ Dependencies installed"
else
echo "⚠️ requirements.txt not found!"
exit 1
fi
# Create instance directory if not exists
if [ ! -d "instance" ]; then
echo "📁 Creating instance directory..."
mkdir -p instance
fi
# Remove old database to create fresh one
if [ -f "instance/accounting.db" ]; then
echo "🗑️ Removing old database..."
rm instance/accounting.db
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🚀 Starting Flask Application..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Run the Flask app
python app.py