Last modified 2 years ago
Using uWSGI on Python 3.x
The WSGI standard has been updated to support python3.x string handling.
The new PEP is the 3333
This is an example of a valid WSGI app for python3.x
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return b'Hello World'
So, all must be unicode "str" object limited to latin1 character set, except for the response body that must be a sequence of zero or more bytes.
uWSGI notes
To support multiple applications via the uwsgi.applications dict you must set the dictionary key as bytes:
import uwsgi
def app1(e, sr):
print(e)
sr('200 Ok', [('Content-Type','text/plain')])
return b'i Am a Python 3.x bytestring'
def app2(e, sr):
print(e)
sr('404 Not Found', [('Content-Type','text/plain')])
return b'i Am a Python 3.x Not Found page'
uwsgi.applications = {b'': app1, b'/test': app2}
