def __init__(self, debug):
root = os.path.dirname(__file__)
static_path = os.path.join(root, 'static')
template_path = os.path.join(root, 'templates')
settings = {
'debug': debug,
'compress_response': True,
'template_path': template_path,
}
# routes
handlers = [
(r'/submit', FormHandler),
(r'/results/?', ResultsSummaryHandler),
(r'/results/([0-9a-fA-F-]+)/?', ResultsHandler),
(r'/tracking/([0-9a-fA-F-]+)/([A-Za-z0-9._-]+)/?', TrackingHandler),
(r'/unsubscribe/([0-9a-fA-F-]+)/?', BlacklistHandler),
(r'/privacy/?', PrivacyHandler),
(r'/', MainHandler),
(r'/(.*)', StaticHandler, {'path': static_path}),
]
# database instance
self.db = db.MailerDatabase(config.DB_PATH)
# rate limiters
self.global_limiter = ratelimit.Bucket(**config.GLOBAL_RATE_LIMIT)
self.ip_limiters = {}
tornado.web.Application.__init__(self, handlers, **settings)
评论列表
文章目录