0

I am new to python and need to develop a web application using jinja framework. On the jinja website, tar file is given and I don't know how to install it on windows. Is it possible to install jinja2 as well as tornado web server on windows-xp?? Is it possible?? if yes then how ?? Please help me as soon as possible

2 Answers2

2

Here is a tutorial I wrote on how to use Jinja2 template engine with Tornado Web Server.

Like mentioned by Kyle, you need to install jinja2 and tornado using pip.

You can write your custom renderer using jinja2 like below.

class JinjaRenderer(tornado.web.RequestHandler):
    def render_template(self, template_name, **kwargs):
        template_dirs = []
        if self.settings.get('template_path', ''):
            template_dirs.append(
            self.settings["template_path"]
        )
        env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dirs))
        try:
            template = env.get_template(template_name)
        except jinja2.TemplateNotFound:
            raise jinja2.TemplateNotFound(template_name)
        return template.render(kwargs)
shicky
  • 927
  • 10
  • 20
1

If you're developing a web app, you're much better off using Linux installed in a VM. I highly recommend using virtualbox.

With that out of the way, let's install it on Windows XP.

Install pip & setuptools. There is already a StackOverflow Q&A for installing pip in Windows.

Once pip is setup (and on your path), run these on the command line (cmd.exe or Powershell):

pip install jinja2
pip install tornado

Note: Other packages may require a compiler. This requires more yak shaving.

Community
  • 1
  • 1
Kyle Kelley
  • 12,557
  • 4
  • 45
  • 75