Writing response body with BaseHTTPRequestHandler
For Python 3, prefix the string literals with a b
:
self.wfile.write(b"<foo>bar</foo>")
In Python3 string is a different type than that in Python 2.x. Cast it into bytes using either
self.wfile.write(bytes("<html><head><title>Title goes here.</title></head>/html>","utf-8"))
or
self.wfile.write("<html><head><title>Title goes here.</title></head></html>".encode("utf-8"))