Error 500 on template.render() with jinja2
Posted
by
Asperitas
on Stack Overflow
See other posts from Stack Overflow
or by Asperitas
Published on 2012-11-02T10:40:57Z
Indexed on
2012/11/02
11:00 UTC
Read the original article
Hit count: 217
I am working on playing with some Python to create a webapp. At first I put the HTML in a string, using %s to fill certain elements. That all worked perfectly. Now I want to put the HTML in a template, so I followed this tutorial.
My code looks like this (I deleted irrelevant code for this error):
import codecs
import cgi
import os
import jinja2
jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__))))
class Rot13Handler(webapp2.RequestHandler):
def get(self):
template = jinja_environment.get_template('rot13.html')
self.response.out.write(template.render({'text': ''}))
When I replace just template.render({'text': ''})
a random string, the program works fine.
I did add the latest jinja2 library to my app.yaml, and naturally my rot13.html does exist with the {{ text }}
added.
So could anyone please help me in the right direction? I don't know why it's going wrong.
© Stack Overflow or respective owner