#!/usr/bin/env bash set -euo pipefail # Install netcat if missing if ! command -v nc >/dev/null 2>&1; then echo "[INFO] Installing netcat..." sudo apt update sudo apt install -y netcat-openbsd fi # Create HTML page with hostname + IP IP="$(hostname -I | awk '{print $1}')" cat > index.html < Hello World

Hello from $(hostname)

IP address: $IP

EOF echo "[INFO] Serving on http://$IP (Ctrl+C to stop)" # Serve forever using netcat while true; do { echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; cat index.html; } | sudo nc -l -p 8080 -q 1 done