Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Applied web development
Lecture: Concept: Anatomy of an HTML form

Login or purchase this course to watch this video and the rest of the course contents.
0:03 Everything we've done so far has been data that the users can consume, but they haven't been able to contribute or edit it in even the simplest way.
0:12 We are going to address that now in the next couple of lectures. So let's start by talking about HTML forms
0:17 specifically within the context of Chameleon templates, but also in general. Here is a form and this is a very simple form,
0:24 what it lets users do is enter their email address and their password and then log into our website. In our website we are just going to say
0:30 the email address is the username, keep it simple. So you can see, everything is contained within a form and forms have actions
0:37 and they have methods, so here the action is just double quote which means it's going to submit back to the same page, that rendered this form,
0:45 so if the page that rendered it was /accounts/signin, it's going to post back, to that exact same URL, and this is usually what you want.
0:55 It also has a method the method is POST, it could be GET, it could be some other thing that might limit us in a few ways,
1:01 typically POST is important, POST communicates to the server that you don't want to be able to cache this,
1:07 you are possibly altering data, things like that. It has a number of input forms, as well as a single button,
1:14 and these input forms have a type so like text and password, and they optionally have a value,
1:20 here we are specifying a value of ${email_address} and ${password} Initially, you can imagine those would be empty.
1:28 But it could be that they submitted this form back to us and they had typed in an email address and there are some kind of reason they couldn't log in,
1:35 but we'd like to preserve that data that they have submitted to us for multiple round trips. So we can do that by refilling,
1:42 repopulating the input fields with whatever data they had entered.


Talk Python's Mastodon Michael Kennedy's Mastodon