3 ms·
There seems to be overlap with wsgiref, and that ships with Python. There's a CGIHandler class that can use stdin/stdout. Most of the examples show spinning u
by tyingq 5y ago
There seems to be overlap with wsgiref, and that ships with Python. There's a CGIHandler class that can use stdin/stdout.
Most of the examples show spinning up and listening to a port, but you can google around to find examples that work with just stdin/stdout.
- tyingq 5y agoSince there's no dead simple examples: #!/usr/bin/env python from wsgiref.handlers import CGIHandler def app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return [ b"<html><head><title>foo</title></head><body>bar</body></html>\n" ] if __name__ == '__main__': CGIHandler().run(app)