Bugfix foo_pep333.py for uwsgi
uwsgi do not handle str, only bytes.
This commit is contained in:
parent
7b22e9278c
commit
1456e35e96
2 changed files with 7 additions and 4 deletions
4
README
4
README
|
|
@ -28,3 +28,7 @@ Example : linking against a debug build of python :
|
|||
logging to file example :
|
||||
-------------------------
|
||||
-L '/tmp/foo.log;0xff;{datetime} {msg} {ident}'
|
||||
|
||||
uwsgi equivalent :
|
||||
------------------
|
||||
uwsgi_python3 --fastcgi-socket 127.0.0.1:9000 --module foo_pep333:entrypoint --processes=5
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from pprint import pformat
|
|||
|
||||
def entrypoint(env, start_response):
|
||||
write_body = start_response("200 OK", [('Content-type', 'text/plain')])
|
||||
|
||||
if not "wsgi.input" in env:
|
||||
raise ValueError("Given environ does not contain any 'wsgi.input' key !")
|
||||
data_in = env["wsgi.input"]
|
||||
|
|
@ -14,8 +13,8 @@ def entrypoint(env, start_response):
|
|||
#data = data_in.readlines()
|
||||
while True:
|
||||
data = data_in.read(98)
|
||||
write_body("POST data : %s\n====\n" % repr(data))
|
||||
write_body(("POST data : %s\n====\n" % repr(data)).encode())
|
||||
if not data:
|
||||
break
|
||||
write_body("Environ data :\n'%s'\n====\n" % pformat(env))
|
||||
return ['Hello world !\n']
|
||||
write_body(("Environ data :\n'%s'\n====\n" % pformat(env)).encode())
|
||||
return [b'Hello world !\n']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue