We're going to be writing bytes. In Python 2 they should go to
sys.stdout, but in Python 3 they should go to sys.stdout.buffer.
if isinstance(p, list):
p = p[0]
url = p.value
- server.serve(url=url, page=page, stream=sys.stdout)
+ stream = sys.stdout # Python 2
+ if hasattr(stream, 'buffer'): # Python 3
+ stream = sys.stdout.buffer
+ server.serve(url=url, page=page, stream=stream)
def serve_scgi(server, host='localhost', port=4000):
import scgi