-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-dev-server.sh
More file actions
executable file
·74 lines (64 loc) · 2.03 KB
/
start-dev-server.sh
File metadata and controls
executable file
·74 lines (64 loc) · 2.03 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
#!/bin/bash
# Development server launcher for Facial Data Collection app
# Tries multiple methods to start a local HTTP server
PORT=8001
echo "🚀 Starting development server for Facial Data Collection..."
echo ""
# Check if port is already in use
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "⚠️ Port $PORT is already in use. Trying to find the process..."
lsof -i :$PORT
echo ""
read -p "Kill existing process and restart? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
lsof -ti :$PORT | xargs kill -9
echo "✓ Killed existing process"
else
echo "❌ Exiting..."
exit 1
fi
fi
cd "$(dirname "$0")/frontend"
# Try Python 3
if command -v python3 &> /dev/null; then
echo "✓ Using Python 3"
echo "📡 Server running at: http://localhost:$PORT"
echo "🔗 Open in browser: http://localhost:$PORT"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""
python3 -m http.server $PORT
# Try Python 2
elif command -v python &> /dev/null; then
echo "✓ Using Python 2"
echo "📡 Server running at: http://localhost:$PORT"
echo "🔗 Open in browser: http://localhost:$PORT"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""
python -m SimpleHTTPServer $PORT
# Try Node.js (http-server)
elif command -v npx &> /dev/null; then
echo "✓ Using Node.js (http-server)"
echo "📡 Server running at: http://localhost:$PORT"
echo ""
npx http-server -p $PORT
# Try PHP
elif command -v php &> /dev/null; then
echo "✓ Using PHP"
echo "📡 Server running at: http://localhost:$PORT"
echo "🔗 Open in browser: http://localhost:$PORT"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""
php -S localhost:$PORT
else
echo "❌ Error: No suitable HTTP server found"
echo ""
echo "Please install one of these:"
echo " - Python 3: sudo apt install python3"
echo " - Node.js: sudo apt install nodejs npm"
echo " - PHP: sudo apt install php"
exit 1
fi