Пример #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()
Пример #3
0
# encoding: utf-8
"""Basic route-based demonstration application.

Applications can be as simple or as complex and layered as your needs dictate.
"""

from web.dialect.route import route


class Root(object):
    __dispatch__ = 'route'

    @route('/')
    def index(self):
        return "Root handler."

    @route('/page/{name}')
    def page(self, name):
        return "Page handler for: " + name


if __name__ == '__main__':
    from web.core.application import Application
    from marrow.server.http import HTTPServer

    HTTPServer('127.0.0.1', 8080, application=Application(Root)).start()