本文整理汇总了Python中tornado.web.Application.handlers方法的典型用法代码示例。如果您正苦于以下问题:Python Application.handlers方法的具体用法?Python Application.handlers怎么用?Python Application.handlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web.Application
的用法示例。
在下文中一共展示了Application.handlers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: url
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import handlers [as 别名]
url(r'/admin/(?:(.+)/?)?', admin.Index, name = 'admin'),
#url(r'/admin/?', admin.Index, name = 'admin'),
url(r'/snippet/?', front.Snippet, name = 'snippet'),
url(r'/login/?', front.Login, name = 'login'),
url(r'/captcha/?', front.Captcha, name = 'captcha'),
url(r'/(.+?)?/?', front.Serve, name = 'serve'),
]
with open('schema2.sql') as f:
import sqlite3
db = sqlite3.connect('data2.db')
db.executescript(f.read())
app = Application(settings['url_map'], **settings)
# Overwrite the Mod Handlers thanks to Tornado being opinionated.
mod_handlers = []
for handler, rules in app.handlers:
handlers = []
for rule in rules:
if 'robots' not in rule.regex.pattern and 'favicon' not in rule.regex.pattern:
handlers.append(rule)
mod_handlers.append((handler, handlers))
app.handlers = mod_handlers
app.listen(8001)
IOLoop.current().start()