mycelia.blog/bin/test_static_page.sh
Brooke 6e0810c0f3
Some checks failed
Hugo / build (push) Has been cancelled
remove backgrounding, more unique port number
2024-03-09 17:02:57 -05:00

27 lines
No EOL
540 B
Bash

#!/bin/bash
PORT=21300
python3 -m http.server $PORT --directory public/
SERVER_PID=$!
# Give it a moment to start
sleep 2
# Check if the server is running
if ! pgrep -P $SERVER_PID > /dev/null; then
echo "HTTP server failed to start."
exit 1
fi
# Check HTTP status
status_code=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:$PORT)
# Kill the http server
kill $SERVER_PID
# Check if status code is 200
if [ "$status_code" -ne 200 ]; then
echo "Website returned a non-200 status code: $status_code"
exit 1
fi