How to get base url of website in jinja2?
google-app-engine, jinja2, python-2.7
Solution
In webapp2, you can get the host part of a request and pass it as argument in a jinja template as follows:
class YourHandler(webapp2.RequestHandler):
def get(self):
params = {'url':self.request.host}
template = jinja_environment.get_template('your_template.html')
self.response.write(template.render(params))
Problem
PHP has `$_SERVER['DOCUMENT_ROOT']` as a reference to the base url of a website: e.g. `http://localhost:8080/`. I need to do the same in `jinja2`. I am using python 2.7 on app engine. How do I get the base url of website in jinja2?