debian-quixote3/quixote/server/cgi_server.py

23 lines
660 B
Python
Raw Normal View History

2016-03-24 23:25:53 +01:00
#!/usr/bin/env python3
2006-03-16 01:58:21 +01:00
import sys
import os
def run(create_publisher):
if sys.platform == "win32":
# on Windows, stdin and stdout are in text mode by default
import msvcrt
msvcrt.setmode(sys.__stdin__.fileno(), os.O_BINARY)
msvcrt.setmode(sys.__stdout__.fileno(), os.O_BINARY)
publisher = create_publisher()
response = publisher.process(sys.__stdin__, os.environ)
try:
response.write(sys.__stdout__)
2016-03-24 23:25:53 +01:00
except IOError as err:
2006-03-16 01:58:21 +01:00
publisher.log("IOError while sending response ignored: %s" % err)
if __name__ == '__main__':
from quixote.demo import create_publisher
run(create_publisher)