CaseInsensitiveDict does not implement .get() yet
This commit is contained in:
parent
6b17c64b15
commit
49527495b8
1 changed files with 5 additions and 5 deletions
|
@ -76,14 +76,14 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||||
return _bot.get_setting("rest-api-minify", False)
|
return _bot.get_setting("rest-api-minify", False)
|
||||||
|
|
||||||
def url_for(self, headers, route, endpoint, get_params={}):
|
def url_for(self, headers, route, endpoint, get_params={}):
|
||||||
hostname = headers.get("Host", None)
|
if "Host" in headers:
|
||||||
if not hostname:
|
host = headers["Host"]
|
||||||
return None
|
|
||||||
else:
|
|
||||||
get_params_str = ""
|
get_params_str = ""
|
||||||
if get_params:
|
if get_params:
|
||||||
get_params = "?%s" % urllib.parse.urlencode(get_params)
|
get_params = "?%s" % urllib.parse.urlencode(get_params)
|
||||||
return "%s/%s/%s%s" % (hostname, route, endpoint, get_params_str)
|
return "%s/%s/%s%s" % (host, route, endpoint, get_params_str)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
def _url_for(self, headers):
|
def _url_for(self, headers):
|
||||||
return lambda route, endpoint, get_params={}: self.url_for(
|
return lambda route, endpoint, get_params={}: self.url_for(
|
||||||
headers, route, endpoint, get_params)
|
headers, route, endpoint, get_params)
|
||||||
|
|
Loading…
Reference in a new issue