-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Python Network Programming Techniques
By :
In this chapter, we will use our Python scripts as both an information source for our template and as the software that starts the rendering of our template into a string that we can then either display or write to a file for later usage.
In this recipe, we will set up the directory structure for our templates and create a Jinja2 environment in our Python script. This Jinja2 environment will then allow us to load and render our first template, written in Jinja2, from Python.
Open your code editor and start by creating a file called render_template.py. Next, navigate your terminal to the same directory that you just created the render_template.py file in.
Next, in the same directory as your Python file, create a directory called templates. Inside of this directory, create a file called first.conf.tpl.
Let's start by writing our Python script to load and render our first template before adding some...