File size: 1,689 Bytes
6640531 |
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 |
#!/bin/bash
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Function to print colored messages
print_message() {
echo -e "${2}${1}${NC}"
}
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
print_message "Python 3 is not installed. Please install Python 3 first." "$RED"
exit 1
fi
# Check Python version
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
print_message "Found Python version: $PYTHON_VERSION" "$GREEN"
# Create virtual environment if it doesn't exist
if [ ! -d ".venv" ]; then
print_message "Creating virtual environment..." "$YELLOW"
python3 -m venv .venv
if [ $? -ne 0 ]; then
print_message "Failed to create virtual environment. Please install python3-venv package." "$RED"
exit 1
fi
fi
# Activate virtual environment
print_message "Activating virtual environment..." "$GREEN"
source .venv/bin/activate
if [ $? -ne 0 ]; then
print_message "Failed to activate virtual environment." "$RED"
exit 1
fi
# Install or upgrade pip
print_message "Upgrading pip..." "$YELLOW"
python3 -m pip install --upgrade pip
# Install requirements
print_message "Installing dependencies..." "$YELLOW"
pip install -r requirements.txt
if [ $? -ne 0 ]; then
print_message "Failed to install dependencies." "$RED"
exit 1
fi
# Start the Flask application
print_message "\n=== DP-SGD Explorer Backend ===" "$GREEN"
print_message "Starting server..." "$GREEN"
print_message "The application will be available at http://127.0.0.1:5000\n" "$YELLOW"
# Set Python path and start server
PYTHONPATH=. python3 run.py |