如何在Python脚本上动态启用/禁用Tornado Auth?

温斯顿

我想要一个启动Tornado的Python脚本。我想仅在生产阶段启用身份验证,而在开发阶段禁用身份验证。

# This is the main page handler
class MainPageHandler(BaseHandler):
    def get(self):
        if not self.get_current_token():
            self.redirect(self.reverse_full_url("tokenLogin"))
            return
        self.render('index.html')

# This is the main tornado app
class Application(tornado.web.Application):
  def __init__(self, disableAuth=False):
    ...

# This is running in main function
Application(disableAuth).listen(PORT, HOST)

我是否可以使用python参数打开/关闭身份验证?一个例子将是非常非常好的。

提前致谢

温斯顿

当前,我将使用全局标志(配置文件中的标志)来照顾传递变量。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章