Skip to content

Instantly share code, notes, and snippets.

@ls0f
Created February 26, 2014 02:10
Show Gist options
  • Save ls0f/9222088 to your computer and use it in GitHub Desktop.
Save ls0f/9222088 to your computer and use it in GitHub Desktop.
login_required for tornado
def login_required(meth):
def deal(self):
if not self.get_secure_cookie("user"):
self.redirect("/user_login/")
return
return meth(self)
return deal
class MainHandler(tornado.web.RequestHandler):
@login_required
def get(self):
self.write("hello,world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment