Figure 14-9. Screenshot of Tradechat login page
Finally, Example 14-6 provides the templating code for the main page. This template does
mainly two things:
Enables commenting
If the user is logged in, a text field and a Post button are shown to allow the user to
post comments.
Displays comments
All comments found in the database are displayed in reverse chronological order
(newest first, oldest last).
Example 14-6. Template for Tradechat main page with chat room comments
{% extends “layout.html” %}
{% block body %}
{% if session.logged_in %}
<form action=“{{ url_for(‘add_entry’) }}” method=post class=add-comment>
- What’s up?
{% endif %}
{% for comment in comments %}