#!/bin/bash # DigiServer v2 - Development Test Runner # This script sets up and runs the application in development mode set -e echo "================================================" echo " DigiServer v2 - Development Environment" echo "================================================" echo "" # Check if we're in the right directory if [ ! -f "requirements.txt" ]; then echo "❌ Error: requirements.txt not found. Run this from the digiserver-v2 directory." exit 1 fi # Check if virtual environment exists if [ ! -d "venv" ]; then echo "📦 Creating virtual environment..." python3 -m venv venv echo "✅ Virtual environment created" else echo "✅ Virtual environment found" fi # Activate virtual environment echo "🔄 Activating virtual environment..." source venv/bin/activate # Install/update dependencies echo "📥 Installing dependencies..." pip install -q --upgrade pip pip install -q -r requirements.txt echo "✅ Dependencies installed" echo "" # Check if .env exists if [ ! -f ".env" ]; then echo "⚠️ Warning: .env file not found, using .env.example" cp .env.example .env fi # Initialize database if it doesn't exist if [ ! -f "instance/dashboard.db" ]; then echo "🗄️ Initializing database..." export FLASK_APP=app.app:create_app flask init-db echo "✅ Database initialized" echo "👤 Creating default admin user..." flask create-admin echo "✅ Admin user created (username: admin, password: admin123)" else echo "✅ Database found" fi echo "" echo "================================================" echo " Starting Flask Development Server" echo "================================================" echo "" echo "🌐 Server will be available at: http://localhost:5000" echo "👤 Default admin: username=admin, password=admin123" echo "" echo "Press Ctrl+C to stop the server" echo "" # Set Flask environment export FLASK_APP=app.app:create_app export FLASK_ENV=development # Run Flask flask run --host=0.0.0.0 --port=5000