In this lesson, you'll learn how to use templates in Flask to create dynamic HTML pages. Templates allow you to separate your Python code from the HTML structure, making your web apps more organised and easier to maintain. You'll build on your knowledge from the previous lesson by adding templates to a Flask application. Here's what you'll do:
By the end, you'll understand how to generate dynamic web pages using Flask templates.
To start, create a dedicated folder for this lesson's project. This will keep your files organised.
FlaskTemplates'. You can place it in your Documents folder or any preferred location.File > Open Folder, then select the 'FlaskTemplates' folder.FlaskTemplates' as your workspace for this lesson.With your project folder ready, you're set to create a terminal in the next step.
Create a virtual environment to isolate your project's dependencies.
View > Command Palette.Python: Create Environment' and select it.Venv' as the type.Python version..venv' folder in 'FlaskTemplates'.Now, open a terminal in VS Code to run commands for setting up your environment.
View > Terminal.pip install flaskYou're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.