You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webssh/main.py

37 lines
1.1 KiB

7 years ago
import logging
import tornado.web
7 years ago
import tornado.ioloop
7 years ago
from tornado.options import parse_command_line, options
7 years ago
from handler import IndexHandler, WsockHandler
from settings import (get_app_settings, get_host_keys_settings,
get_policy_setting)
7 years ago
7 years ago
def make_app(loop, policy, host_keys_settings, app_settings):
7 years ago
handlers = [
(r'/', IndexHandler, dict(loop=loop, policy=policy,
host_keys_settings=host_keys_settings)),
(r'/ws', WsockHandler, dict(loop=loop))
7 years ago
]
app = tornado.web.Application(handlers, **app_settings)
7 years ago
return app
def main():
parse_command_line()
app_settings = get_app_settings(options)
host_keys_settings = get_host_keys_settings(options)
policy = get_policy_setting(options, host_keys_settings)
loop = tornado.ioloop.IOLoop.current()
app = make_app(loop, policy, host_keys_settings, app_settings)
7 years ago
app.listen(options.port, options.address)
logging.info('Listening on {}:{}'.format(options.address, options.port))
loop.start()
7 years ago
if __name__ == '__main__':
main()