15 lines
410 B
Python
15 lines
410 B
Python
def BASE_URL(request):
|
|
"""
|
|
Return a BASE_URL template context for the current request.
|
|
"""
|
|
if request.is_secure():
|
|
scheme = 'https://'
|
|
else:
|
|
scheme = 'http://'
|
|
fullhost = request.get_host()
|
|
port = fullhost.split(":")[1]
|
|
if port == 80 or port == 443:
|
|
base = fullhost.split(":")[0]
|
|
else:
|
|
base = fullhost
|
|
return {'BASE_URL': scheme + base, } |