Python Flask Basics Character Builder Starting the Builder

Lucas Navalesi
Lucas Navalesi
3,600 Points

Where does the key "name" come from?

Maybe I'm asking something very obvious but I can not understand ...

{{Save.get ('name', '')}}

1) "saves" is equal to "data". In turn, "save" is the json (and dict?) Conversion of the cookie we set in the func "save ()" ... right?

2) With json.dumps what we did was a str of a dict of an immutable dict that we delivered the form. To that result we established it as the cookie ...?

3) In the unlikely event that pts 1 and 2 are fine ... at what time we have the key "name" in our cookie? "Name" is by default?

Thank you !!!

2 Answers

Zach Swift
Zach Swift
17,972 Points

The 'name' key comes from the html form. If you look at line 9 in builder.html, the input element has a name property with a value of name. When the form is submitted, the data is sent to flask in a dictionary like object with the name property and whatever the user entered as the value. Now in, in the save function on line 28, you're updating the character cookie dict with the keys and values of the form.