I\'m playing a little with Python 3.2.2 and want to write a simple web server to access some data remotely. This data will be generated by Python so I don\'t want to use the Sim
For Python 3, prefix the string literals with a b
:
self.wfile.write(b"<foo>bar</foo>")
Just use this when using Python 3.X
self.wfile.write(bytes("<body><p>This is a test.</p>", "utf-8"))
based on your code #comments you're probably looking for self.headers.getheaders('referer'), ie:
if 'http://www.icamefromthissite.com/' in self.headers.getheaders('referer'):
do something
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"))