Get the full request path

1
2
3
def get_full_path(request):
    full_path = ('http', ('', 's')[request.is_secure()], '://', request.META['HTTP_HOST'], request.path)
    return ''.join(full_path)

More like this

  1. Serve static media files from app/media subdirectory by adamlofts 5 years, 8 months ago
  2. Get the referer view of a request by arthurfurlan 4 years, 11 months ago
  3. Database file storage by powerfox 5 years, 2 months ago
  4. server with debugging backdoor by teepark 5 years, 7 months ago
  5. FilterManager by sergejdergatsjev 5 years, 4 months ago

Comments

robbie (on March 6, 2007):

To be a bit more redundant, you could make that:

def get_full_path(request):
    return 'http' + ('', 's')[request.is_secure()] + '://' + request.META['HTTP_HOST'] + request.path

...or better:

def get_full_path(request):
    full_path = ('http', ('', 's')[request.is_secure()], '://', request.META['HTTP_HOST'], request.path)
    return ''.join(full_path)

#

limodou (on March 6, 2007):

Thanks. I lost secure.

#

(Forgotten your password?)