Exemple #1
0
def main():
    parse_command_line(final=False)
    parse_config_file(options.config_file)

    app = Application([
        ('/', MainHandler),
        ('/login', LoginHandler),
        ('/logout', LogoutHandler),
    ],
                      login_url='/login',
                      **options.group_dict('application'))
    app.listen(options.port)

    logging.info('Listening on http://localhost:%d' % options.port)
    IOLoop.current().start()
Exemple #2
0
def main():
    parse_command_line()
    app = Application([('/', ChunkHandler)])
    app.listen(options.port, address='127.0.0.1')

    def callback(response):
        response.rethrow()
        assert len(response.body) == (options.num_chunks * options.chunk_size)
        logging.warning("fetch completed in %s seconds", response.request_time)
        IOLoop.current().stop()

    logging.warning("Starting fetch with curl client")
    curl_client = CurlAsyncHTTPClient()
    curl_client.fetch('http://localhost:%d/' % options.port, callback=callback)
    IOLoop.current().start()

    logging.warning("Starting fetch with simple client")
    simple_client = SimpleAsyncHTTPClient()
    simple_client.fetch('http://localhost:%d/' % options.port,
                        callback=callback)
    IOLoop.current().start()
Exemple #3
0
#!/usr/bin/env python

from censiotornado.ioloop import IOLoop
from censiotornado.options import define, options, parse_command_line
from censiotornado.websocket import WebSocketHandler
from censiotornado.web import Application

define('port', default=9000)


class EchoHandler(WebSocketHandler):
    def on_message(self, message):
        self.write_message(message, binary=isinstance(message, bytes))

    def get_compression_options(self):
        return {}


if __name__ == '__main__':
    parse_command_line()
    app = Application([
        ('/', EchoHandler),
    ])
    app.listen(options.port, address='127.0.0.1')
    IOLoop.instance().start()