Python Flask Basics Welcome to Flask Request Variables

Qui Le
Qui Le
6,116 Points

What is request.args.get() method? and Why is the first argument to this method is a string 'name'?

Want to understand more about request function from flask

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 56,933 Points

The flask Request object contains the attributes of the URL request. The args attribute is a dictionary containing arguments from the URL. The get() method is a built-in dictionary method that will “get” an item from a dictionary or return a default value (None if key not found). In this case, it avoids a KeyError if “name” argument not found.

Post back if you need more help. Good luck!!!

Qui Le
Qui Le
6,116 Points

Thank you, Chris!!