Added test_app.py
This commit is contained in:
+8
-6
@@ -8,25 +8,27 @@ from settings import (get_app_settings, get_host_keys_settings,
|
||||
get_policy_setting)
|
||||
|
||||
|
||||
def make_app(loop, policy, host_keys_settings, app_settings):
|
||||
def make_handlers(loop, options):
|
||||
host_keys_settings = get_host_keys_settings(options)
|
||||
policy = get_policy_setting(options, host_keys_settings)
|
||||
|
||||
handlers = [
|
||||
(r'/', IndexHandler, dict(loop=loop, policy=policy,
|
||||
host_keys_settings=host_keys_settings)),
|
||||
(r'/ws', WsockHandler, dict(loop=loop))
|
||||
]
|
||||
return handlers
|
||||
|
||||
|
||||
def make_app(handlers, app_settings):
|
||||
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 = make_app(make_handlers(loop, options), get_app_settings(options))
|
||||
app.listen(options.port, options.address)
|
||||
logging.info('Listening on {}:{}'.format(options.address, options.port))
|
||||
loop.start()
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ def get_app_settings(options):
|
||||
template_path=os.path.join(base_dir, 'templates'),
|
||||
static_path=os.path.join(base_dir, 'static'),
|
||||
cookie_secret=uuid.uuid4().hex,
|
||||
xsrf_cookies=True,
|
||||
xsrf_cookies=(not options.debug),
|
||||
debug=options.debug
|
||||
)
|
||||
return settings
|
||||
|
||||
Reference in New Issue
Block a user