Here is the code to create a HTTP server with a HEAD route in Python:
main.py517 chars17 linesThe RequestHandler class overrides the do_HEAD method to handle the HEAD request. In this example, it simply sends a 200 response with the content type header set to text/html.
The run function creates an instance of HTTPServer using server_class and handler_class, and starts the server on the specified port. When the server is started, it will print a message to the console indicating the port number.
Note that, in this example, the server will run indefinitely until it is manually stopped. To stop the server, simply press Ctrl+C in the console.
gistlibby LogSnag