本文整理汇总了Python中tornado.web.Application.redis方法的典型用法代码示例。如果您正苦于以下问题:Python Application.redis方法的具体用法?Python Application.redis怎么用?Python Application.redis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web.Application
的用法示例。
在下文中一共展示了Application.redis方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import redis [as 别名]
def main():
define('debug', default=False, help='debug', type=bool)
define('port', default=1900, help='port', type=int)
define('rds_host', default='127.0.0.1', help='Redis host')
define('rds_port', default=6379, help='Redis port', type=int)
define('rds_db', default=0, help='Redis database', type=int)
parse_command_line()
settings['debug'] = options.debug
application = Application(handlers, **settings)
application.redis = redis.StrictRedis(host=options.rds_host, port=options.rds_port, db=options.rds_db)
http_server = HTTPServer(application, xheaders=True)
http_server.listen(options.port)
logging.info('Listen on %d, debug=%s' % (options.port, options.debug))
IOLoop.instance().start()
示例2: Application
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import redis [as 别名]
if not self.current_password:
if username == "flyking" and password == "112358":
self.set_secure_cookie("username", username)
self.session.password = password
self.redirect("/")
else:
raise tornado.web.HTTPError(403, "user or password error")
else:
self.redirect("/")
urls = [
(r"/", MainHandler),
(r"/login", LoginHandler),
]
settings = {
"cookie_secret":"61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=", # 带签名的cookie
"login_url":"/login",
# "xsrf_cookies":"Ture", # 跨站伪造请求(Cross-site request forgery) 防范策略 xsrf_cookies
}
app = Application(urls, **settings)
app.listen(8888)
app.redis = client.Redis()
app.SessionHandler = SessionHandler
IOLoop.instance().start()