VJC Chapter 8 Web Applications (Jinja) Part 2
Uploaded by cheesemuffin · 10 December 2025
Preview
Chapter 8: Web applications (Jinja) Part 2 Contents 1 What is jinja? 2 Jinja Syntax 3 Using url_for 4 Filters 5 Conditional statements 5.1 If statements 5.2 For statements 6 External Cascading Style Sheet 7 Handling file and image upload Syllabus Learning Outcomes 4.2 Web Applications Understand the concepts and techniques for developing web applications. 4.2.3 Use HTML, CSS (for clients) and Python (for the server) to create a web application that is able to: – accept user input (text and image file uploads) – process the input on the local server – store and retrieve data using an SQL database – display the output (as formatted text/images/table). 4.2.4 Test a web application on a local server. 1
1 What is jinja? Jinja is a popular and powerful template engine for Python web development. It is designed to be easy to use and flexible, allowing developers to build complex and dynamic web applications with ease. Jinja provides a simple syntax for creating templates, which can be used to generate HTML, XML, and other markup languages. With Jinja, developers can separate the presentation layer from the business logic, making it easier to maintain and update their web applications. Jinja is also extensible, allowing developers to create their own custom filters and extensions to further enhance their templates. 2 Jinja Syntax Jinja has been introduced in Web Applications (Flask) part 1. Now, let's delve deeper into the various elements that make up the Jinja syntax, which are utilized for defining and manipulating templates. Type Syntax Description Variables {{ }} Variables in Jinja are defined using the {{ }} tags. They are used to output dynamic content in the template. Example: {{ name }} in greet.html Control Structures {% if condition %} …… {% else %} …… {% endif %} In each of these examples, the control structure is defined using opening and closing tags, such as {% if %} and {% endif %} for if/else statements, and {% for %} and {% endfor %} for loops. The content to be executed within the control structure is then placed between these tags. {% for item in items %} … {% endfor %} Comments {# #} Comments in Jinja are define using the {# #} tags. They are used to add comments to the template that are ignored during rendering. Inheritance {% extends %} Inheritance in Jinja allows templates to inherit content from a base template. This is done using the {% extends %}
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

