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
In the `templates` folder, you see `.jade` files instead of `.html` templates, and the views in `views.py` refer to these files in their calls to `flask.render_template`. Otherwise the views code is the same.
168
168
169
169
Opening one of the `.jade` files, you can see the more succinct expression of a template. For example, here's the contents of `templates/layout.jade` as created by the "Flask/Jade Web Project" template:
Copy file name to clipboardExpand all lines: docs/python/learn-flask-visual-studio-step-05-polls-flask-web-project-template.md
+55-55Lines changed: 55 additions & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -73,35 +73,35 @@ As noted before. much of what's in a project created from the "Polls Flask Web P
73
73
74
74
The data models for the app are Python classes named Poll and Choice, which are defined in `models/__init__.py`. A Poll represents a question, for which a collection of Choice instances represent the available answers. A Poll also maintains the total number of votes (for any choice) and a method to calculate statistics that are used to generate views:
75
75
76
-
```python
77
-
class Poll(object):
78
-
"""A poll object for use in the application views and repository."""
79
-
def __init__(self, key=u'', text=u''):
80
-
"""Initializes the poll."""
81
-
self.key = key
82
-
self.text = text
83
-
self.choices = []
84
-
self.total_votes = None
85
-
86
-
def calculate_stats(self):
87
-
"""Calculates some statistics for use in the application views."""
"""A poll choice object for use in the application views and repository."""
98
+
def__init__(self, key=u'', text=u'', votes=0):
99
+
"""Initializes the poll choice."""
100
+
self.key = key
101
+
self.text = text
102
+
self.votes = votes
103
+
self.votes_percentage =None
104
+
```
105
105
106
106
These data models are generic abstractions that allow the app's views to work against different types of backing data stores, which are described in the next step.
107
107
@@ -184,32 +184,32 @@ The following steps add support for a different data store than the three provid
184
184
185
185
Initially, any chosen data store contains no polls, so the app's home page shows the message "No polls available" along with the **Create Sample Polls** button. Once you select the button, however, the view changes to display available polls. This switch happens through conditional tags in `templates\index.html` (some blank lines omitted for brevity):
0 commit comments