Fix encoding issues
This commit is contained in:
parent
1a612baef1
commit
0f50285b9b
8
main.py
8
main.py
|
@ -17,9 +17,9 @@ HTTP400 = "400 Bad Request"
|
|||
HTTP405 = "405 Method Not Allowed"
|
||||
HTTP500 = "500 Internal Server Error"
|
||||
|
||||
HTML = "text/html"
|
||||
JSON = "application/json"
|
||||
XML = "text/xml"
|
||||
HTML = "text/html; charset=UTF-8"
|
||||
JSON = "application/json; charset=UTF-8"
|
||||
XML = "text/xml; charset=UTF-8"
|
||||
|
||||
DOCSTR = ' Check out the <a href="https://kumig.it/kumitterer/oebb_py#request">documentation</a> for usage instructions.'
|
||||
|
||||
|
@ -27,6 +27,7 @@ def doConn(req):
|
|||
try:
|
||||
getfrm = req.cfrm if "cfrm" in dir(req) and req.cfrm else req.args["from"][0] if "from" in req.args else None
|
||||
getto = req.cto if "cto" in dir(req) and req.cto else req.args["to"][0] if "to" in req.args else None
|
||||
|
||||
try:
|
||||
frm = html.unescape(getfrm.encode("latin-1").decode("utf-8"))
|
||||
to = html.unescape(getto.encode("latin-1").decode("utf-8"))
|
||||
|
@ -37,6 +38,7 @@ def doConn(req):
|
|||
if not frm or not to:
|
||||
raise ValueError()
|
||||
|
||||
|
||||
except Exception:
|
||||
content = "<h1>400 Bad Request</h1>\n"
|
||||
content += "\"from\"and \"to\" values are required for this type of request."
|
||||
|
|
|
@ -3,7 +3,7 @@ import urllib.parse
|
|||
from classes import *
|
||||
|
||||
def getValidator(name):
|
||||
data = HTTPClient().get("http://scotty.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&" % urllib.parse.quote(name)).text
|
||||
data = HTTPClient().get("http://scotty.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S='%s'?&js=true&" % urllib.parse.quote(name.encode("latin-1"))).text
|
||||
return "=".join(data.split("=")[1:]).split(";")[0]
|
||||
|
||||
def validateName(name):
|
||||
|
|
Loading…
Reference in New Issue