本文整理汇总了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)
示例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)
示例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"])
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)