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?
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?
webapp2
is based onWebOb
. From their docsAccessing the application URL is enabled by the
request
object in a handler and can be accessed via the attributeapplication_url
:In webapp2, you can get the host part of a request and pass it as argument in a jinja template as follows: