I am using a simple setup for serving static files in CherryPy:
class StaticServer(object):
pass
config = {
'/': {
'tools.encode.on': True,
'tools.encode.encoding': 'utf-8',
'tools.staticdir.on': True,
'tools.staticdir.dir': fullpath,
'tools.staticdir.index': 'index.html',
'error_page.default': error_page
}
}
cherrypy.tree.mount(StaticServer(), "/", config = config)
However, when loading the index.html page (which is UTF-8 encoded), it is not served correctly, resulting in jumbled characters. When checking the response header, I can see the content-type: text/html, but no character set encoding.
How can I set the character set encoding to UTF-8 in CherryPy for statically served files?