From d9c560e590291369c8f51e6858d12c7e9a7dddbd Mon Sep 17 00:00:00 2001 From: Stephan Hadan Date: Tue, 28 Jan 2025 09:08:13 +0100 Subject: [PATCH] added test_static_page.sh script --- bin/test_static_page.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/test_static_page.sh diff --git a/bin/test_static_page.sh b/bin/test_static_page.sh new file mode 100755 index 0000000..99bdb97 --- /dev/null +++ b/bin/test_static_page.sh @@ -0,0 +1,26 @@ +#!/bin/bash +PORT=8080 +python3 -m http.server $PORT --directory public/ & + +SERVER_PID=$! + +# Give it a moment to start +sleep 2 + +# Check if the server is running +if ! ps -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