Repository navigation
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·54 lines (47 loc) · 1.57 KB
/
Copy pathlaunch.sh
File metadata and controls
executable file
·54 lines (47 loc) · 1.57 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
#!/bin/bash
# Configuration
PORT=${1:-8080}
DIRECTORY="learning-app"
# Find a suitable python command (prefer venv if present)
if [ -f "venv/bin/python3" ]; then
PYTHON_CMD="venv/bin/python3"
elif [ -f "venv/bin/python" ]; then
PYTHON_CMD="venv/bin/python"
elif command -v python3 &>/dev/null; then
PYTHON_CMD="python3"
elif command -v python &>/dev/null; then
PYTHON_CMD="python"
else
echo "Error: Python is required to run the local server but was not found." >&2
exit 1
fi
# Function to automatically open the web app in the default browser
open_browser() {
sleep 1 # Give the server a second to start up
URL="http://localhost:$PORT/index.html"
echo "Opening $URL in your browser..."
if [[ "$OSTYPE" == "darwin"* ]]; then
open "$URL"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v xdg-open &>/dev/null; then
xdg-open "$URL"
fi
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
start "$URL"
fi
}
# Run browser opening function in the background
open_browser &
echo "========================================================"
echo " Designing Data-Intensive Applications Learning App"
echo "========================================================"
echo "Directory: $DIRECTORY"
echo "Port: $PORT"
echo "Python: $PYTHON_CMD"
echo ""
echo "👉 Open directly: http://localhost:$PORT/index.html"
echo "👉 Press Ctrl+C to shut down the server"
echo "========================================================"
echo ""
# Start the Flask app server
$PYTHON_CMD server.py "$PORT"