当前位置: 首页>>代码示例>>Python>>正文


Python Application.__init__方法代码示例

本文整理汇总了Python中tornado.web.Application.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Application.__init__方法的具体用法?Python Application.__init__怎么用?Python Application.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.web.Application的用法示例。


在下文中一共展示了Application.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):

        settings = dict(
            debug=options.debug,
            xsrf_cookies=False,
            db=StockApplication.db,
            test_db=StockApplication.test_db,
            cookie_secret=options.cookie_secret,
            login_url="/login",
            static_path=os.path.join(here, "static")
        )
        paths = {"path": "./static"}
        handlers = [
            (r"/?", HomeHandler),
            (r"/condition/(macd|kdj|price)/?", ConditionHandler),
            (r"/algo/(upload|remove|list)/?", AlgoHandler),
            (r"/stock-list/?", StockListHandler),
            (r"/login/?", AuthLoginHandler),
            (r"/logout/?", AuthLogoutHandler),
            (r"/kdj/(day|hour|week)/?", KDJHandler),
            (r"/macd/(day|hour|week)/?", MACDHandler),
            (r"/static/(.*)", tornado.web.StaticFileHandler, paths)

        ]

        Application.__init__(self, handlers, **settings)
开发者ID:guoyr,项目名称:stockup-backend,代码行数:28,代码来源:data_server.py

示例2: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
 def __init__(self):
     settings = {}
     settings["debug"] = True
     handlers = []
     handlers.extend(UploadWebService.get_handlers())
     self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
     Application.__init__(self, handlers, **settings)
开发者ID:Bossuo,项目名称:ppmessage,代码行数:9,代码来源:tornadouploadapp.py

示例3: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self, opts, profiles):
        """init server, add route to server"""       
        settings = dict(
            template_path           = os.path.join(os.path.dirname(__file__), "core/tpl"),
            static_path             = os.path.join(os.path.dirname(__file__), "core/static"),            
            cookie_name             = opts.server_name,
            cookie_secret           = opts.cookie_secret,
            xsrf_cookie             = True,
            session_secret          = opts.session_secret,
            session_timeout         = int(opts.session_timeout),
            memcached_address       = ["127.0.0.1:11211"],
            login_url               = "/accounts/login",
            ui_modules              = uimodules,
            debug                   = bool(opts.debug),
            weibo_key               = opts.weibo_key,
            weibo_secret            = opts.weibo_secret,
            tencent_key             = opts.tencent_key,
            tencent_secret          = opts.tencent_secret,
            douban_key              = opts.douban_key,
            douban_secret           = opts.douban_secret,
            opts                    = opts,
            profiles                = profiles
        )
        
        Application.__init__(self, handlers, **settings)

        self.session_manager = session.SessionManager(settings["session_secret"], 
                                                      settings["memcached_address"], 
                                                      settings["session_timeout"])
        self.mc = pylibmc.Client(["127.0.0.1"])
开发者ID:ergatea,项目名称:gitpub2,代码行数:32,代码来源:engine.py

示例4: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
       
        settings = {}
        settings["debug"] = True
        settings["cookie_secret"] = "PzEMu2OLSsKGTH2cnyizyK+ydP38CkX3rhbmGPqrfBs="

        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        DownloadHandler.set_cls_redis(self.redis)
        _root = os.path.abspath(os.path.dirname(__file__)) + "/ppkefu/www"

        _generic_store = BOOTSTRAP_DATA.get("server")
        _generic_store = _generic_store.get("generic_store")
        
        handlers = [
            (r"^/$", MainHandler),
            (r"^/cordova.js$", CordovaHandler),
            (r"/js/(.*)", StaticFileHandler, {"path": _root + "/js"}),
            (r"/build/(.*)", StaticFileHandler, {"path": _root + "/build"}),
            (r"/css/(.*)", StaticFileHandler, {"path": _root + "/css"}),
            (r"/templates/(.*)", StaticFileHandler, {"path": _root + "/templates"}),
            (r"/lib/(.*)", StaticFileHandler, {"path": _root + "/lib"}),
            (r"/img/(.*)", StaticFileHandler, {"path": _root + "/img"}),
            
            (r"/download/(.*)", DownloadHandler, {"path": "/"}),
            (r"/icon/([^\/]+)?$", StaticFileHandler, {"path": _generic_store + os.path.sep}),
            (r"/material/([^\/]+)?$", MaterialFileHandler, {"path": _generic_store + os.path.sep}),
            (r"/upload/(.*)", UploadHandler),
        ]

        Application.__init__(self, handlers, **settings)
开发者ID:1733604733,项目名称:ppmessage,代码行数:32,代码来源:ppkefu.py

示例5: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        # handlers = [
        #      (r'/', IndexHandler),
        #
        #     # 所有html静态文件都默认被StaticFileHandler处理
        #      # (r'/tpl/(.*)', StaticFileHandler, {
        #      #     'path': os.path.join(os.path.dirname(__file__), 'templates')
        #      # }),
        #      # PC端网页
        #      # (r'/f/', RedirectHandler, {'url': '/f/index.html'}),
        #      # (r'/f/(.*)', StaticFileHandler, {
        #      #     'path': os.path.join(os.path.dirname(__file__), 'front')
        #      # }),
        #  ]
        handlers = []
        handlers.extend(nui.routes)
        handlers.extend(service.routes)
        handlers.extend(stock.routes)
        handlers.extend(smscenter.routes)
        handlers.extend(weui.routes)
        handlers.extend(routes)
        site_url_prefix = settings.get(constant.SITE_URL_PREFIX, "")
        if site_url_prefix:
            # 构建新的URL
            handlers = map(
                lambda x: url(site_url_prefix + x.regex.pattern, x.handler_class, x.kwargs, x.name), handlers
            )

        # handlers = get_handlers()

        # 配置默认的错误处理类
        settings.update({"default_handler_class": ErrorHandler, "default_handler_args": dict(status_code=404)})

        Application.__init__(self, handlers=handlers, **settings)
开发者ID:hulingfeng211,项目名称:mywork,代码行数:36,代码来源:manage.py

示例6: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self, handlers=None, default_host="", transforms=None, wsgi=False, **settings):
        if not handlers:
            handlers = [
                (r"/_/api/changes", ChangeRequestHandler),
                (r"/_/api/?(.*)", APIRequestHandler),
                (r"/_/?(.*)", AssetsHandler, {"path": os.path.join(module_path(), '_')}),
                (r"/", RedirectHandler, {'url': '/_/index.html'}),
            ]
        if not settings:
            settings = {
                'debug': True,
                'template_path': os.path.join(module_path(), '_'),
            }
        if not default_host:
            default_host = '.*$'

        Application.__init__(self, handlers, default_host, transforms, wsgi, **settings)
        self.internal_handler_count = len(handlers)

        self.change_request_handlers = set()
        self.observer = ChangesObserver(changes_handler=self.change_happened)

        self.config_path = config_path()
        self.config = self.load_config()
        self.project = None
        for project in self.config.get('projects', []):
            if project.get('isCurrent'):
                self.project = project
                self.set_project(project)
                break
开发者ID:flashhtml5,项目名称:PyF5,代码行数:32,代码来源:server.py

示例7: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        settings = load_settings(config)
        handlers = [
            (r'/$', StaticHandler, dict(
                template_name='index.html',
                title=settings['site_title']
            )),
            (r'/drag', StaticHandler, dict(
                template_name='draggable.html',
                title=settings['site_title']
            )),
            (r'/http', StaticHandler, dict(
                template_name='httpdemo.html',
                title=settings['site_title']
            )),
            (r'/demo', HTTPDemoHandler),
            (r'/demo/quickstart',StaticHandler,dict(
                template_name='App/demo/quickstart.html'
            )),
            (r'/user/list', UserHandler),
            (r'/user', UserHandler),#post
            (r'/user/(\w+)', UserHandler),#delete
        ]

        self.db = settings['db']
        self.dbsync = settings['dbsync']

        Application.__init__(self, handlers, **settings)
开发者ID:hulingfeng211,项目名称:angularjs,代码行数:30,代码来源:manage.py

示例8: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        handlers = [
            (r"/", IndexHandler),
            (r"/schedule", ScheduleHandler),
            (r"/recently", RecentlyViewHandler),
            (r"/overview", OverViewHandler),
            (r"/domains", DomainsViewHandler),
            (r"/details", DomainDetailHandler),
        ]
        config = dict(
            template_path=os.path.join(os.path.dirname(__file__), settings.TEMPLATE_ROOT),
            static_path=os.path.join(os.path.dirname(__file__), settings.STATIC_ROOT),
            #xsrf_cookies=True,
            cookie_secret="__TODO:_E720135A1F2957AFD8EC0E7B51275EA7__",
            autoescape=None,
            debug=settings.DEBUG
        )
        Application.__init__(self, handlers, **config)

        self.rd_main = redis.Redis(settings.REDIS_HOST,
                                   settings.REDIS_PORT,
                                   db=settings.REDIS_DB)
        self.db = Connection(
            host=settings.MYSQL_HOST, database=settings.MYSQL_DB,
            user=settings.MYSQL_USER, password=settings.MYSQL_PASS)
开发者ID:yidun55,项目名称:crawler,代码行数:27,代码来源:app.py

示例9: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        logging.getLogger().setLevel(options.logging_level)

        if options.debug:
            logging.warn("==================================================================================")
            logging.warn("SERVER IS RUNNING IN DEBUG MODE! MAKE SURE THIS IS OFF WHEN RUNNING IN PRODUCTION!")
            logging.warn("==================================================================================")

        logging.info("Starting server...")

        # apollo distribution root
        dist_root = os.path.join(os.path.dirname(__file__), "..", "..")

        Application.__init__(
            self,
            [
                (r"/",                  FrontendHandler),
                (r"/session",           SessionHandler),
                (r"/action",            ActionHandler),
                (r"/events",            EventsHandler),
                (r"/dylib/(.*)\.js",    DylibHandler)
            ],
            dist_root   = dist_root,
            static_path = os.path.join(dist_root, "static"),
            debug       = options.debug
        )

        self.loader = Loader(os.path.join(dist_root, "template"))

        setupDBSession()

        self.dylib_dispatcher = DylibDispatcher(self)
        self.bus = Bus(self)
        self.plugins = PluginRegistry(self)
        self.cron = CronScheduler(self)
开发者ID:thecowboy,项目名称:apollo,代码行数:37,代码来源:core.py

示例10: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
 def __init__(self, _web):
     self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
     settings = {}
     settings["debug"] = True
     handlers = []
     handlers.extend(_web)            
     Application.__init__(self, handlers, **settings)
开发者ID:1733604733,项目名称:ppmessage,代码行数:9,代码来源:srvapp.py

示例11: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self, extra_handlers):
        '''Expects a list of tuple handlers like:
                [(r"/", MainHandler), (r"/chatsocket", ChatSocketHandler),]
        '''
        url = settings._server_str % (settings.PROTOCOL, settings.HOSTNAME, settings.AUTHSERVERPORT)

        app_settings = {
                "cookie_secret": settings.COOKIE_SECRET,
                "login_url": ''.join((url, "/login")),
                }

        handlers = []
        handlers.append((r"/version", VersionHandler))
        handlers.append((r"/source", SelfServe))
        handlers.append((r"/ping", PingHandler))
        handlers.append((r"/", PingHandler))

        handlers.extend(extra_handlers)

        options.parse_command_line()
        dburi = options.dburi

        # Connect to the elixir db
        setup(db_uri=dburi)

        Application.__init__(self, handlers, debug=True, **app_settings)
开发者ID:cnelsonsic,项目名称:SimpleMMO,代码行数:28,代码来源:baseserver.py

示例12: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        handlers = [
            (r"/login", auth_handlers.LoginHandler),
        ]
        ui_modules = {
        }
        settings = dict(
            #debug
            debug = True,

            #set modules
            ui_modules = ui_modules,

            #tornado template lookup
            template_path  = os.path.join(PROJECT_DIR, "templates"),

            #tornado httpserver static path
            static_path = os.path.join(PROJECT_DIR, "static"),

            #tmp file path
            tmp_path = os.path.join(PROJECT_DIR, "tmp"),

            #tornado auth login url
            login_url = "/login",

            #cookie settings
            xsrf_cookies = False,
            cookie_secret = 'thy_secret',

        )
        Application.__init__(self, handlers, **settings)
开发者ID:tuhuayuan,项目名称:gobangme,代码行数:33,代码来源:site.py

示例13: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self, settings):
        config = dict(
            template_path=os.path.join(os.path.dirname(__file__),
                                       settings.TEMPLATE_ROOT),
            static_path=os.path.join(os.path.dirname(__file__),
                                     settings.STATIC_ROOT),
            cookie_secret="__E720175A1F2957AFD8EC0E7B51275EA7__",
            login_url='/login',
            autoescape=None,
            debug=settings.DEBUG
        )
        Application.__init__(self, handlers, **config)

        conn = S3Connection()
        self.bucket = conn.get_bucket(settings.APK_BUCKET)
        self.redis = redis.Redis(
            host=settings.REDIS_HOST,
            port=settings.REDIS_PORT,
            db=settings.REDIS_DB,
            password=settings.REDIS_PASS
        )

        self.db = MotorReplicaSetClient(
            settings.MONGO_CONNECTION_STRING,
            replicaSet='android'
        )[settings.MONGO_DB]

        self.engine = Base(settings)
        self.api = self.engine.login(async=True)
开发者ID:hw20686832,项目名称:android_crawler,代码行数:31,代码来源:app.py

示例14: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        super(RobotApp, self).__init__(*args, **kwargs)

        # every app_uuid get its svm, vector, target (label->string).
        self.svm = {}
        self.vector = {}
        # target string array
        self.target = {}

        _key = AppInfo.__tablename__ + ".uuid." + self._app_uuid
        _robot_uuid = self.redis.hget(_key, "robot_user_uuid")
        if _robot_uuid == None:
            logging.error("no robot user uuid")
            sys.exit()
            
        self.robot_user_uuid = _robot_uuid

        self.robot_key = REDIS_ROBOT_KEY
        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        self.predict_answer_handler = PredictAnswerHandler(self)
        self.predict_user_handler = PredictUserHandler(self)
        self.fit_handler = FitHandler(self)
        
        settings = {}
        settings["debug"] = True
        handlers = []
        Application.__init__(self, handlers, **settings)

        return
开发者ID:1733604733,项目名称:ppmessage,代码行数:31,代码来源:robot.py

示例15: __init__

# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import __init__ [as 别名]
    def __init__(self):
        handlers = [
           (r'/',IndexHandler),

           # 所有html静态文件都默认被StaticFileHandler处理
           (r'/tpl/(.*)',StaticFileHandler,{
               'path':os.path.join(os.path.dirname(__file__),'templates')
           }),
           # PC端网页
           (r'/f/',RedirectHandler,{'url':'/f/index.html'}),
           (r'/f/(.*)',StaticFileHandler,{
               'path':os.path.join(os.path.dirname(__file__),'front')
           }),
           # 手机端网页
           (r'/m/',RedirectHandler,{'url':'/m/index.html'}),
           (r'/m/(.*)',StaticFileHandler,{
               'path':os.path.join(os.path.dirname(__file__),'mobile')
           }),
        ]
        handlers.extend(auth.route)
        handlers.extend(message.route)
        handlers.extend(rbac.route)
        handlers.extend(ds.route)
        handlers.extend(weui.routes)
        handlers.extend(mobile.route)
        Application.__init__(self, handlers=handlers, **settings)
开发者ID:hulingfeng211,项目名称:weixin,代码行数:28,代码来源:manage.py


注:本文中的tornado.web.Application.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。