Redirect web2py to previous page

When from a page I iterate over another page through some hyperlink, is there any way to return to the previous page. The previous page also has some arguments. I want to ask if the previous page is saved somewhere or is there another way to return to this page.

+3
source share
2 answers

There is a header field in http called "referrer". If present, it points to the previous page. You can access it from web2py:

if request.env.http_referer:
    redirect(request.env.http_referer)
+6
source

, , , . , - :

if session.back:
    redirect_url = session.back
else:
    redirect_url = URL()

# create form, do stuff, etc.
if form.accepts(request.vars.session):
    session.back = None
else:
    session.back = request.env.http_referer
+3

Source: https://habr.com/ru/post/1781461/


All Articles