This shows you the differences between two versions of the page.
ii:labs:s2:03:tasks:01 [2022/05/04 15:33] radu.ciobanu [01. [10p] Testing the Docker installation] |
ii:labs:s2:03:tasks:01 [2024/04/01 21:59] (current) florin.stancu [01. [40p] Splitting web pages into Jinja2 templates] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 01. [10p] Testing the Docker installation ==== | + | ==== 01. [40p] Splitting web pages into Jinja2 templates ==== |
- | Start a container that runs the official //**hello-world**// image and check that everything functions correctly. | + | First, {{ii:labs:s2:lab03-flask-advanced-skel.zip|download the lab archive}}. |
+ | |||
+ | We now want to move the design from last time (a static ''html'' file) to use Flask Jinja2-based template rendering. | ||
+ | |||
+ | For this, you must: | ||
+ | |||
+ | * Migrate / split the HTML code into ''templates/_base.html'' (base template) and ''templates/index.html'' (child); | ||
+ | * //Note:// use Jinja2 [[https://jinja.palletsprojects.com/en/3.1.x/templates/#template-inheritance|template inheritance]] and content blocks; | ||
+ | * Make sure to eliminate any duplicate code (the ''_base.html'' template should contain the common layout of all pages)! | ||
+ | * Modify ''server.py'' to call ''render_template'' from router functions to actually serve our new design; | ||
+ | * Also create ''second.html'' and fill the Flask function to serve it (fill it with whatever content you want, like in the [[ii:labs:s2::02|previous lab]]); | ||
+ | * Finally, fix the URLs in the base template's menu to point to the appropriate pages. | ||
- | To show that you implemented this exercise correctly, you need to upload: | ||
- | * a screenshot showing the successful execution of the Hello World container. |