commit a39657a0be35f3972667a9fb5dfbe8e327917289
parent b88a159fbb3bdebf087f732672962b41430d2610
Author: Sheng <webmaster0115@gmail.com>
Date: Sun, 22 Apr 2018 18:32:21 +0800
Added make_app
Diffstat:
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/main.py b/main.py
@@ -8,13 +8,7 @@ from settings import (get_app_settings, get_host_keys_settings,
get_policy_setting)
-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()
-
+def make_app(loop, policy, host_keys_settings, app_settings):
handlers = [
(r'/', IndexHandler, dict(loop=loop, policy=policy,
host_keys_settings=host_keys_settings)),
@@ -22,6 +16,17 @@ def main():
]
app = tornado.web.Application(handlers, **app_settings)
+ 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)
app.listen(options.port, options.address)
logging.info('Listening on {}:{}'.format(options.address, options.port))
loop.start()