Dec-07-2022, 10:27 PM
I'm doing some authentication tests through the http header, but the browser's login prompt window isn't being triggered? I think I'm forgetting something, below is the example:
from wsgiref.simple_server import make_server def app(environ, start_response): status = "401 Unauthorized" headers = [ ("Content-type", "text/plain; charset=utf-8"), ("WWW-Authenticate:", "Basic realm=Access to the internal site") ] start_response(status, headers) # The returned object is going to be printed return [b"401 Unauthorized"] with make_server("", 8000, app) as httpd: print("Serving on port 8000...") # Serve until process is killed httpd.serve_forever()