You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: load_multiple_users.md
+20-21
Original file line number
Diff line number
Diff line change
@@ -27,10 +27,10 @@ Flask provides us with the `flask-wtf` package that allows for the creation of w
27
27
28
28
### Create a Registration Form
29
29
30
-
Following the principle of _separation of concerns_, we will create a `forms` module with will hold all the forms our application will need. Inside `app/` subfolder, create an empty form called `forms.py`.
30
+
Following the principle of _separation of concerns_, we will create a `forms` module which will hold all the forms our application will need. Inside `app/` subfolder, create an empty form called `forms.py`.
31
31
32
32
```python
33
-
(venv) $mkdir app/forms.py
33
+
(venv) $touch app/forms.py
34
34
```
35
35
36
36
We will begin by creating a registration form. This form will collect the same information from both students and teachers.
@@ -51,7 +51,7 @@ class RegisterForm(FlaskForm):
51
51
submit = SubmitField('Register')
52
52
```
53
53
54
-
`Flask-wtf` provides several fields and validators that we have used to create the registration form. The first is the `StringField` which is used to collect a string of characters. The second is the `PasswordField`which is used to collect a string of characters. The third is the `EqualTo` validator which is used to compare the value of the password field to the value of the confirm password field. `DataRequired` ensures that the field needs to be field, otherwise clicking the submit button won't work. The last field is the `SubmitField` which is used to submit the form.
54
+
`Flask-wtf` provides several fields and validators that we have used to create the registration form. The first is the `StringField` which is used to collect a string of characters. Same to the `PasswordField`. The `SubmitField`is used to submit the form. The `EqualTo` validator is used to compare the value of the password field to the value of the confirm password field. `DataRequired` ensures that the field needs to be field, otherwise clicking the submit button won't work.
55
55
56
56
### Display the Registration Form
57
57
@@ -73,7 +73,7 @@ Within the `app/templates`, we will create a `register.html` file. This file wil
73
73
{% endblock %}
74
74
```
75
75
76
-
In a single line of code, we are able to display the registration form. We are using the `wtf.quick_form` macro to create the form. The `wtf.quick_form` function takes in a form as an argument. We will use the `form` variable to store the form. The good thing here is that our form has all the styles needed to look good, thanks to the Bootstrap framework.
76
+
In a single line of code, we are able to display the registration form. We have used the `wtf.quick_form` macro to create the form. The `wtf.quick_form` function takes in a form as an argument. We will use the `form` variable to store the form. The good thing here is that our form has all the styles needed to look good, thanks to the Bootstrap framework.
We are sourcing the value of the `SECRET_KEY` from an environment variable. If the variable is not set, we will use the string `you-will-never-guess`.
138
-
139
-
The next step will be to register this configuration module within the application instance.
140
-
141
-
`__init__.py: Register the Configuration Module`
142
-
```python
143
-
# ...
144
-
from config import Config
145
-
146
-
# ...
147
-
app.config.from_object(Config)
148
-
149
-
# ...
150
-
```
151
-
152
-
To add this enviroment variable, we will do so in the `.env` file. Create this file in the top-level directory of our application.
137
+
We are sourcing the value of the `SECRET_KEY` from an environment variable. If the variable is not set, we will use the string `you-will-never-guess`. To add this enviroment variable, we will do so in the `.env` file. Create this file in the top-level directory of our application.
153
138
154
139
```python
155
140
(venv) $ touch .env
@@ -167,7 +152,21 @@ As the name suggests, this value should be secret, and hard to guess. I was able
0 commit comments