The upload form allows users to upload images to the Dark Chest of
Wonders screenshot gallery. No authentication, etc. is performed, so
this needs to be handled by the web server.
The `set_payload` method of the `VariedResponse` class takes care of
rendering the Jinja template or serializing the context object as JSON,
so that no longer needs to be handled by controllers.
The `VariedResponse` class essentially turns the website into a REST
API. When a controller returns a response object that is an instance of
this class, the response representation sent to the user-agent will vary
based on the value of the `Accept` request header. Specifically,
requests containing `Accept: application/json` will receive a
JSON-encoded object, while typical browser requests will get an (X)HTML
document.
The WSGI specification requires that URL-paths be encoded as ISO-8859-1
(Latin-1). For filenames that only use ASCII characters, this works
correctly. When a filename includes characters encoded in other
character sets, however, the thumbnail controller will return always
HTTP 404 if the local filesystem does not also use the Latin-1 character
set.
To work around this discrepancy and ensure that requested file names are
looked up on the local filesystem correctly, the string must be
re-encoded in the proper character set.