Send a GET request and show the status code
Print only the HTTP status code of a request with curl -s -o /dev/null -w '%{http_code}'. The exit status stays 0 for a 404 unless you add --fail.
A health check needs the status code of a URL, not the body, and a script wants it on a line of its own.
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/index.txt
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/missing
curl -s -o /dev/null http://127.0.0.1:8000/missing; echo "exit: $?"
curl -s -f -o /dev/null http://127.0.0.1:8000/missing; echo "exit with -f: $?"200
404
exit: 0
exit with -f: 22-w prints a format after the transfer, and %{http_code} is one of the variables listed on the curl man page. With -o /dev/null the body is discarded and -s hides the progress meter, so the code is all that is printed. A 404 is still a completed transfer for curl, so the exit status stays 0 until -f turns an HTTP error into exit 22.
The code reported is the last one, after any redirect you asked curl to follow with -L. Add %{url_effective} to see where it ended. A refused connection prints 000 as the code, so treat 000 as "no response", not as a status.