Correctly handle UTF-8 server names.

This fixes a problem where the page does not display properly if a
server name contains a non-ASCII character (see discussion on
chocolate-doom/chocolate-doom#229).
This commit is contained in:
Simon Howard 2014-10-19 21:36:56 +01:00
parent 2cc103e783
commit 65704ad398

View file

@ -164,7 +164,7 @@ def read_template(filename):
""" Read HTML template file. """ """ Read HTML template file. """
file = open(filename) file = open(filename)
result = file.read() result = file.read().decode('utf8')
file.close() file.close()
return result return result
@ -172,9 +172,9 @@ def read_template(filename):
def output_html(html): def output_html(html):
""" Output HTML data back to client. """ """ Output HTML data back to client. """
print "Content-Type: text/html" print "Content-Type: text/html; charset=utf-8"
print print
print html sys.stdout.write(html.encode('utf8'))
template = read_template("index.template") template = read_template("index.template")