def __init__(self): settings = dict( site_title=u"Insurance search", template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), ui_modules={"InsuranceEntry": InsuranceEntry}, # xsrf_cookies=True, cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", login_url="/auth/login", debug=options.debug, ) handles = route.get_routes() # defined with route decorators tornado.web.Application.__init__(self, handles, **settings) self.solr_path = options.solr_path
def main(): tornado.options.parse_command_line() if options.showurls: for each in route.get_routes(): print each._path.ljust(20), "mapping to RequestHandle-->", each.handler_class.__name__ http_server = tornado.httpserver.HTTPServer(Application()) print "Starting tornado server 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
def __init__(self, mysql_database=None): settings = dict( site_title=u"Insurance search", template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), # ui_modules={"InsuranceEntry": InsuranceEntry}, # xsrf_cookies=True, cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", login_url="/auth/login", debug=options.debug, ) handles = route.get_routes() # defined with route decorators tornado.web.Application.__init__(self, handles, **settings) self.database = mysql_database and mysql_database or options.mysql_database self.db = torndb.Connection( host=options.mysql_host, database=self.database, user=options.mysql_user, password=options.mysql_password) self.solr_path = options.solr_path self.static_path = settings["static_path"]