-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStart_OSC_Webapp.command
More file actions
executable file
·85 lines (68 loc) · 2.12 KB
/
Copy pathStart_OSC_Webapp.command
File metadata and controls
executable file
·85 lines (68 loc) · 2.12 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# ================================
# OSC HTTP WebApp - Launcher Mac
# ================================
echo "Starting OSC HTTP WebApp..."
echo "=================================="
cd "$(dirname "$0")" || exit 1
if [ ! -d "venv" ]; then
echo "Error: venv directory not found. Run install.sh first."
read -p "Press Enter to close..."
exit 1
fi
echo "Working directory: $(pwd)"
# Activate venv first - this puts the right python in PATH
source venv/bin/activate
# Find working python
if command -v python3 &>/dev/null; then
PYTHON=python3
elif command -v python &>/dev/null; then
PYTHON=python
else
echo "Error: No Python found after activating venv."
read -p "Press Enter to close..."
exit 1
fi
echo "Using: $PYTHON ($($PYTHON --version 2>&1))"
# Check dependencies
if [ -f "requirements.txt" ]; then
echo "Checking dependencies..."
$PYTHON -m pip install -r requirements.txt --quiet 2>/dev/null
fi
if [ ! -f "mini_osc.py" ]; then
echo "Error: mini_osc.py not found."
read -p "Press Enter to close..."
exit 1
fi
if [ ! -f "config.json" ]; then
echo "Error: config.json not found."
read -p "Press Enter to close..."
exit 1
fi
FLASK_IP=$($PYTHON -c "import json; cfg=json.load(open('config.json')); print(cfg['flask_server']['ip'])" 2>/dev/null)
FLASK_PORT=$($PYTHON -c "import json; cfg=json.load(open('config.json')); print(cfg['flask_server']['port'])" 2>/dev/null)
if [ -z "$FLASK_IP" ] || [ -z "$FLASK_PORT" ]; then
FLASK_IP="127.0.0.1"
FLASK_PORT="5000"
fi
echo "=================================="
echo "Flask server: http://$FLASK_IP:$FLASK_PORT"
echo "=================================="
sleep 3 && open "http://$FLASK_IP:$FLASK_PORT" &
echo "Launching application..."
echo "Press Ctrl+C to stop"
echo "=================================="
# Loop: restart app when it exits with code 42 (restart requested from web UI)
while true; do
$PYTHON mini_osc.py
EXIT_CODE=$?
if [ $EXIT_CODE -ne 42 ]; then
break
fi
echo ""
echo "Restarting application..."
sleep 2
done
echo ""
echo "Application stopped"
read -p "Press Enter to close..."