How to get current url in web2py?

In web2py how to get the full url of the current page? I want a (possibly rewritten) URL that appears in the address bar of the browser.

eg. http://www.example.com/products/televisions?sort=price&page=2

+3
source share
2 answers

The easiest way to generate this is probably:

URL(args=request.args, vars=request.get_vars, host=True)

You can also compile the URL like this:

'%s://%s%s' % (request.env.wsgi_url_scheme, request.env.http_host,
               request.env.web2py_original_uri)
+9
source

I know this is an old thread - this is what I needed in 2017 to get the original url:

url = '%s://%s%s' % (request.env.wsgi_url_scheme, request.env.http_host,
           request.env.request_uri)

Close to the previous answer, but uri was in a different place.

+2
source

All Articles