24 lines
495 B
Bash
24 lines
495 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Make a minimal HTML page
|
|
IP="$(hostname -I | awk '{print $1}')"
|
|
cat > index.html <<EOF
|
|
<html>
|
|
<head><title>Hello World</title></head>
|
|
<body>
|
|
<h1>Hello from $(hostname)</h1>
|
|
<p>IP address: $IP</p>
|
|
</body>
|
|
</html>
|
|
EOF
|
|
|
|
# Serve forever on port 80 with netcat
|
|
echo "Serving on http://$IP (Ctrl+C to stop)"
|
|
while true; do
|
|
{
|
|
echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
|
|
cat index.html;
|
|
} | nc -l -p 8080 -q 1
|
|
done
|