Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current url in web2py?

Tags:

url

web2py

In web2py how do I get the complete url of the current page? I want the (possibly rewritten) url that appears in the browser address bar.

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

like image 880
User Avatar asked Dec 06 '22 03:12

User


2 Answers

The easiest method to generate this is probably:

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

You could also assemble the URL this way:

'%s://%s%s' % (request.env.wsgi_url_scheme, request.env.http_host,
               request.env.web2py_original_uri)
like image 141
Anthony Avatar answered Jan 03 '23 18:01

Anthony


I know this is an old thread - this is what it took for me 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 the uri was elsewhere.

like image 35
drchuck Avatar answered Jan 03 '23 18:01

drchuck