def __init__(self,root,settings,xsrf_cookies=True): self.root = root self.app_settings = settings ui_modules_map = self._load_ui_module() handlers = route.get_routes() app_settings = dict( title=settings.site.title, template_path=os.path.join(root, "apps", "templates"), static_path=os.path.join(root, "static"), ui_modules=ui_modules_map, xsrf_cookies=xsrf_cookies, cookie_secret=settings.site.cookie_secret, login_url=settings.site.login_url, debug=options.debug, optimize_static_content=settings.site.optimize_static_content, webmaster=settings.site.webmaster, feedback=settings.site.feedback, closure_location=os.path.join(root, "static", "compiler.jar"), yui_location=os.path.join(root, "static", "yuicompressor-2.4.2.jar"), cdn_prefix = settings.site.cdn ) self._load_handlers() _load_models(settings) _load_mq_handlers(settings) tornado.web.Application.__init__(self, handlers, **app_settings)
def start_web(args, settings): if options.showurls: for each in route.get_routes(): print each._path.ljust(60), print each.handler_class.__name__ return http_server = tornado.httpserver.HTTPServer(Application(settings.root, settings)) print datetime.now(),"Starting tornado on port", options.port if options.prefork: print "\tpre-forking" http_server.bind(options.port) http_server.start() else: http_server.listen(options.port) try: tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: pass