Python HTTP server supporting encoded encoding?

I am looking for a well-supported Python multi-threaded HTTP server that supports alternating encoding responses. (Ie "Transmit-Encoding: chunked" for answers). What is the best HTTP server for?

+5
source share
4 answers

Twisted supports encoded transmission encoding (API reference) (see also API document for HTTPChannel ). There are a number of production-class projects using Twisted (for example, Apple uses it for the iCalendar server on Mac OS X Server), so it is pretty well supported and very reliable.

+5

. , , , Request.write.

+2

, , WSGI, . , WSGI , -. , .

, , WSGI- , , Python CGIHTTPServer. , .

0

I succeeded using Tornado :

#!/usr/bin/env python

import logging

import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web

from tornado.options import define, options

define("port", default=8080, help="run on the given port", type=int)

@tornado.web.stream_request_body
class MainHandler(tornado.web.RequestHandler):
    def post(self):
        print()
    def data_received(self, chunk):
        self.write(chunk)

        logging.info(chunk)

def main():
    tornado.options.parse_command_line()

    application = tornado.web.Application([
        (r"/", MainHandler),
    ])

    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)

    tornado.ioloop.IOLoop.current().start()

if __name__ == "__main__":
    main()
0
source

All Articles