File size: 1,615 Bytes
d51321a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo -e "${GREEN}Starting Uvify UI Server...${NC}"

# Check if node_modules exists
if [ ! -d "node_modules" ]; then
    echo -e "${YELLOW}Installing Node dependencies...${NC}"
    npm install
fi

# Activate Python virtual environment
if [ -d ".venv" ]; then
    source .venv/bin/activate
else
    echo -e "${YELLOW}Creating Python virtual environment...${NC}"
    uv venv
    source .venv/bin/activate
    echo -e "${YELLOW}Installing Python dependencies...${NC}"
    uv pip install 'uvify[api]'
fi

# Create .env file if it doesn't exist
if [ ! -f ".env" ]; then
    cp .env.example .env
    echo -e "${YELLOW}Created .env file from .env.example${NC}"
fi

# Function to cleanup on exit
cleanup() {
    echo -e "\n${YELLOW}Shutting down servers...${NC}"
    kill $UVIFY_PID $VITE_PID 2>/dev/null
    exit
}

trap cleanup EXIT INT TERM

# Start uvify backend server
echo -e "${GREEN}Starting Uvify backend server on http://localhost:8000${NC}"
# Use our CORS wrapper to handle cross-origin requests
python uvify_cors_wrapper.py &
UVIFY_PID=$!

# Wait a moment for the backend to start
sleep 2

# Start Vite frontend server
echo -e "${GREEN}Starting Vite frontend server on http://localhost:5173${NC}"
npm run dev &
VITE_PID=$!

echo -e "${GREEN}Both servers are running!${NC}"
echo -e "Frontend: ${GREEN}http://localhost:5173${NC}"
echo -e "Backend API: ${GREEN}http://localhost:8000${NC}"
echo -e "\nPress ${YELLOW}Ctrl+C${NC} to stop both servers"

# Wait for both processes
wait $UVIFY_PID $VITE_PID