Fix encoding issues
This commit is contained in:
parent
1a612baef1
commit
0f50285b9b
2 changed files with 6 additions and 4 deletions
8
main.py
8
main.py
|
@ -17,9 +17,9 @@ HTTP400 = "400 Bad Request"
|
||||||
HTTP405 = "405 Method Not Allowed"
|
HTTP405 = "405 Method Not Allowed"
|
||||||
HTTP500 = "500 Internal Server Error"
|
HTTP500 = "500 Internal Server Error"
|
||||||
|
|
||||||
HTML = "text/html"
|
HTML = "text/html; charset=UTF-8"
|
||||||
JSON = "application/json"
|
JSON = "application/json; charset=UTF-8"
|
||||||
XML = "text/xml"
|
XML = "text/xml; charset=UTF-8"
|
||||||
|
|
||||||
DOCSTR = ' Check out the <a href="https://kumig.it/kumitterer/oebb_py#request">documentation</a> for usage instructions.'
|
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:
|
try:
|
||||||
getfrm = req.cfrm if "cfrm" in dir(req) and req.cfrm else req.args["from"][0] if "from" in req.args else None
|
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
|
getto = req.cto if "cto" in dir(req) and req.cto else req.args["to"][0] if "to" in req.args else None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frm = html.unescape(getfrm.encode("latin-1").decode("utf-8"))
|
frm = html.unescape(getfrm.encode("latin-1").decode("utf-8"))
|
||||||
to = html.unescape(getto.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:
|
if not frm or not to:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
content = "<h1>400 Bad Request</h1>\n"
|
content = "<h1>400 Bad Request</h1>\n"
|
||||||
content += "\"from\"and \"to\" values are required for this type of request."
|
content += "\"from\"and \"to\" values are required for this type of request."
|
||||||
|
|
|
@ -3,7 +3,7 @@ import urllib.parse
|
||||||
from classes import *
|
from classes import *
|
||||||
|
|
||||||
def getValidator(name):
|
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]
|
return "=".join(data.split("=")[1:]).split(";")[0]
|
||||||
|
|
||||||
def validateName(name):
|
def validateName(name):
|
||||||
|
|
Loading…
Reference in a new issue