示例#1
0
 def do():
     
     server = HTTPServer(host=host, port=port, application=hello, threading=threads)
     
     def handle_sigchld(sig, frame):
         server.io.add_callback(server.stop)
     
     signal.signal(signal.SIGCHLD, handle_sigchld)
     
     server.start(testing=IOLoop.instance())
     proc = subprocess.Popen("ab -n 10000 -c 25 http://%s:%d/" % (host, port), shell=True)
     server.io.start()
#!/usr/bin/env python
# encoding: utf-8

import logging
from marrow.server.http import HTTPServer
from marrow.wsgi.egress.compression import CompressionFilter


def hello(request):
    return b"200 OK", [(b"Content-Type", b"text/plain"), (b"Content-Length", b"100")], [b"a" * 100]


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    server = HTTPServer(None, 8080, application=hello, egress=[CompressionFilter(level=1)])
    server.start()