Sunday, May 1, 2011

Python CGI and Jinaj2 Templates - Part I

I'm getting ready for the Summer 2011 Web Application Development program we will be offering at the Governor's Career and Technical Academy in Arlington.

I've long wanted to be able to use a simple template engine to create headers and footers on websites.  I've been using the PHP include statement for this purpose, but I would really like to use the Python Jinja2 engine instead.

It appears I may be able to work on my bluehost web hosting account.  Here is what I did:
  1. Edit the .bash_profile file and add the following:
    PYTHONPATH=$HOME/lib/python
        export PYTHONPATH
    
  2. Download the Jinja2 source tarball from here.
  3. Extract the source directory from the .tar.gz file and cd into the new directory.
  4. Run: python setup.py install --home=~ (see this for more on that ;-)
I was able to import jinja2 in a python shell, create a template and call render on it.  I will report back later as I progress from here...

    No comments:

    Post a Comment