'Where does the csrf_token() function come from in flask_wtf.csrf?
I've implemented a flask app and needed to use a CSRF token. The code looks something like this:
<form method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
</form>
The jinja templating uses the csrf_token() function, which I assumed was coming from Python. However, the function isn't imported or initialized anywhere, so I was wondering if maybe it's initialized when the CSRFProtect function is run? It looks like this when we import and initialize things:
from flask import Flask
from flask_wtf.csrf import CSRFProtect
app = Flask(__name__)
csrf = CSRFProtect(app)
The docs are here: https://flask-wtf.readthedocs.io/en/0.15.x/csrf/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
