Skip to content

Instantly share code, notes, and snippets.

@msrkp

msrkp/tornado.js Secret

Created November 21, 2020 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msrkp/3a0918cf555d2a9997f04365d59e9b3c to your computer and use it in GitHub Desktop.
Save msrkp/3a0918cf555d2a9997f04365d59e9b3c to your computer and use it in GitHub Desktop.
tornado
def xsrf_form_html(self) -> str:
"""An HTML ``<input/>`` element to be included with all POST forms.
It defines the ``_xsrf`` input value, which we check on all POST
requests to prevent cross-site request forgery. If you have set
the ``xsrf_cookies`` application setting, you must include this
HTML within all of your HTML forms.
In a template, this method should be called with ``{% module
xsrf_form_html() %}``
See `check_xsrf_cookie()` above for more information.
"""
return (
'<input type="hidden" name="_xsrf" value="'
+ escape.xhtml_escape(self.xsrf_token)
+ '"/>'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment