I keep finding answers on how to read a redirect from an HTTP client response out of Python, but I can't figure out how to send a 301 or 302 redirect back to the client. Seems this should work, but I always get a 200 response before the body:
print("Content-Type: text/html; charset=UTF-8\n")
print("HTTP/1.1 301 Moved Permanently")
print("Location:", "https://www.google.com/")
The equivalent PHP code would simply be:
// Redirect the browser to Google
header("Location: https://www.google.com/", true, 301);