Parcourir la source

[minor] take default site address from conf.host_name if mentioned #211

version-14
Rushabh Mehta il y a 12 ans
Parent
révision
92a68e1e44
1 fichiers modifiés avec 13 ajouts et 7 suppressions
  1. +13
    -7
      webnotes/utils/__init__.py

+ 13
- 7
webnotes/utils/__init__.py Voir le fichier

@@ -83,13 +83,19 @@ def validate_email_add(email_str):

def get_request_site_address(full_address=False):
"""get app url from request"""
import os
try:
return 'HTTPS' in os.environ.get('SERVER_PROTOCOL') and 'https://' or 'http://' \
+ os.environ.get('HTTP_HOST')\
+ (full_address and (os.environ.get("REQUEST_URI")) or "")
except TypeError:
return 'http://localhost'
import os, conf
if hasattr(conf, "host_name"):
return conf.host_name
else:
try:
protocol = 'HTTPS' in os.environ.get('SERVER_PROTOCOL') and 'https://' or 'http://'
host = os.environ.get('HTTP_HOST')
if full_address:
return protocol + host + os.environ.get("REQUEST_URI")
else:
return protocol + host
except TypeError:
return 'http://localhost'

def random_string(length):
"""generate a random string"""


Chargement…
Annuler
Enregistrer