Translation_app_ / scripts /start_demo.sh
Athena1621's picture
feat: Implement Multi-Lingual Product Catalog Translator frontend with Streamlit
67f25fb
#!/bin/bash
echo "========================================"
echo " Multi-Lingual Catalog Translator"
echo " Quick Demo Deployment"
echo "========================================"
echo
echo "πŸ”§ Checking prerequisites..."
if ! command -v python3 &> /dev/null; then
echo "❌ Python3 not found! Please install Python 3.11+"
exit 1
fi
echo "βœ… Python3 found"
echo
# Function to cleanup on exit
cleanup() {
echo
echo "πŸ›‘ Stopping services..."
if [ ! -z "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null
fi
if [ ! -z "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null
fi
echo "βœ… Services stopped"
exit 0
}
# Setup signal handlers
trap cleanup SIGINT SIGTERM
echo "πŸš€ Starting Backend Server..."
cd backend
echo "Starting Backend API on port 8001..."
uvicorn main:app --host 0.0.0.0 --port 8001 &
BACKEND_PID=$!
cd ..
echo
echo "⏳ Waiting for backend to initialize (15 seconds)..."
sleep 15
echo
echo "🎨 Starting Frontend Server..."
cd frontend
echo "Starting Streamlit Frontend on port 8501..."
streamlit run app.py --server.port 8501 &
FRONTEND_PID=$!
cd ..
echo
echo "βœ… Deployment Complete!"
echo
echo "πŸ“± Access your application:"
echo "πŸ”— Frontend UI: http://localhost:8501"
echo "πŸ”— Backend API: http://localhost:8001"
echo "πŸ”— API Docs: http://localhost:8001/docs"
echo
echo "πŸ’‘ Tips:"
echo "- Wait 30-60 seconds for models to load"
echo "- Check logs below for loading progress"
echo "- Press Ctrl+C to stop all services"
echo
echo "πŸŽ‰ Application is now running!"
echo "Opening frontend in browser..."
# Try to open browser (works on most systems)
if command -v xdg-open &> /dev/null; then
xdg-open http://localhost:8501
elif command -v open &> /dev/null; then
open http://localhost:8501
else
echo "Please open http://localhost:8501 in your browser"
fi
echo
echo "πŸ“Š Monitoring logs (Press Ctrl+C to stop):"
echo "----------------------------------------"
# Wait for processes to finish or for interrupt
wait