Commit 1fee3146 by Sheng

Clean code

parent 614d6e8a
...@@ -2,7 +2,7 @@ import logging ...@@ -2,7 +2,7 @@ import logging
import tornado.web import tornado.web
import tornado.ioloop import tornado.ioloop
from tornado.options import parse_command_line, options from tornado.options import options
from webssh.handler import IndexHandler, WsockHandler from webssh.handler import IndexHandler, WsockHandler
from webssh.settings import (get_app_settings, get_host_keys_settings, from webssh.settings import (get_app_settings, get_host_keys_settings,
get_policy_setting, max_body_size) get_policy_setting, max_body_size)
...@@ -20,13 +20,12 @@ def make_handlers(loop, options): ...@@ -20,13 +20,12 @@ def make_handlers(loop, options):
return handlers return handlers
def make_app(handlers, app_settings): def make_app(handlers, settings):
app = tornado.web.Application(handlers, **app_settings) return tornado.web.Application(handlers, **settings)
return app
def main(): def main():
parse_command_line() options.parse_command_line()
loop = tornado.ioloop.IOLoop.current() loop = tornado.ioloop.IOLoop.current()
app = make_app(make_handlers(loop, options), get_app_settings(options)) app = make_app(make_handlers(loop, options), get_app_settings(options))
app.listen(options.port, options.address, max_body_size=max_body_size) app.listen(options.port, options.address, max_body_size=max_body_size)
......
...@@ -36,7 +36,6 @@ def get_app_settings(options): ...@@ -36,7 +36,6 @@ def get_app_settings(options):
settings = dict( settings = dict(
template_path=os.path.join(base_dir, 'webssh', 'templates'), template_path=os.path.join(base_dir, 'webssh', 'templates'),
static_path=os.path.join(base_dir, 'webssh', 'static'), static_path=os.path.join(base_dir, 'webssh', 'static'),
cookie_secret=uuid.uuid4().hex,
websocket_ping_interval=options.wpIntvl, websocket_ping_interval=options.wpIntvl,
xsrf_cookies=(not options.debug), xsrf_cookies=(not options.debug),
debug=options.debug debug=options.debug
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment