2018-10-24 23:57:41 +02:00
|
|
|
def BASE_URL(request):
|
|
|
|
"""
|
|
|
|
Return a BASE_URL template context for the current request.
|
|
|
|
"""
|
|
|
|
if request.is_secure():
|
|
|
|
scheme = 'https://'
|
|
|
|
else:
|
|
|
|
scheme = 'http://'
|
2018-10-25 01:29:30 +02:00
|
|
|
fullhost = request.get_host()
|
2018-11-30 22:02:41 +01:00
|
|
|
host = fullhost.split(":")[0]
|
|
|
|
port = request.get_port()
|
2018-11-28 23:13:12 +01:00
|
|
|
if port == 80 or port == 443:
|
2018-11-30 22:02:41 +01:00
|
|
|
base = host
|
2018-11-28 23:13:12 +01:00
|
|
|
else:
|
2018-11-30 22:02:41 +01:00
|
|
|
base = host+":"+port
|
2018-10-25 01:29:30 +02:00
|
|
|
return {'BASE_URL': scheme + base, }
|