File: server.py

package info (click to toggle)
python-tornado 4.4.2-1~bpo8%2B2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 3,020 kB
  • sloc: python: 25,036; sh: 130; xml: 49; ansic: 45; makefile: 45; sql: 26
file content (23 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

from tornado.ioloop import IOLoop
from tornado.options import define, options, parse_command_line
from tornado.websocket import WebSocketHandler
from tornado.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()