What are the differences between flask.request.form["xxx"]
, flask.request.form.get("xxx")
and flask.request.args.get("xxx")
?
I have this question because I am using flask-login to handle authentication.
In particular in the following code (taken from the flask-login github page), I don't understand why with req.form.get("email")
, email is None
, while with req.form["email"]
, email hasn't a value. Here's the code.
@login_manager.request_loader
def request_loader(req):
email = req.form.get('email')
if email not in users:
return
user = User()
user.id = email
# DO NOT ever store passwords in plaintext and always compare password
# hashes using constant-time comparison!
user.is_authenticated = req.form['pw'] == users[email]['pw']
return user