Initial import: web4beginners editor and deployment setup

This commit is contained in:
2026-03-06 13:49:43 +01:00
commit fd9ea482bf
73 changed files with 4043 additions and 0 deletions

34
serve-offline.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
PORT="${1:-4173}"
PID_FILE=".offline-server.pid"
LOG_FILE=".offline-server.log"
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
echo "Offline server already running on PID $(cat "$PID_FILE")."
echo "Open: http://127.0.0.1:${PORT}/"
exit 0
fi
rm -f "$PID_FILE"
ln -sf web4beginners.com.html index.html
nohup python3 -m http.server "$PORT" --bind 127.0.0.1 >"$LOG_FILE" 2>&1 &
SERVER_PID=$!
echo "$SERVER_PID" > "$PID_FILE"
sleep 0.3
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo "Failed to start offline server on port $PORT."
echo "Check log: $ROOT_DIR/$LOG_FILE"
rm -f "$PID_FILE"
exit 1
fi
echo "Offline server started (PID $SERVER_PID)."
echo "Open: http://127.0.0.1:${PORT}/"
echo "Log: $ROOT_DIR/$LOG_FILE"