Created
August 31, 2012 13:06
-
-
Save cjgiridhar/3552449 to your computer and use it in GitHub Desktop.
Tornado - XSRF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
class Page(tornado.web.RequestHandler): | |
def get(self): | |
self.render('xsrfform.html') | |
def post(self): | |
name = self.get_argument("name") | |
self.write('Helo ' + name) | |
application = tornado.web.Application([ | |
(r"/page", Page), | |
], | |
debug=True, | |
xsrf_cookies=True, | |
cookie_secret="61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=" | |
) | |
if __name__ == "__main__": | |
application.listen(8888) | |
tornado.ioloop.IOLoop.instance().start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<title> | |
Login | |
</title> | |
<body> | |
<form action="/page" method="post"> | |
{% module xsrf_form_html() %} | |
Username: <input type="text" name="name"/> | |
<input type="submit" name="login" value="Login"/> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment