Fix access

This commit is contained in:
Klaus-Uwe Mitterer 2017-10-12 19:40:43 +02:00
parent 43110f8d17
commit d29b5555e3

10
main.py
View file

@ -123,16 +123,16 @@ def application(env, re):
yield "device is required.".encode()
return
on = args["on"] if "on" in args else None
frm = on if on else args["from"] if "from" in args else None
to = on if on else args["to"] if "to" in args else None
on = args["on"][0] if "on" in args else None
frm = on if on else args["from"][0] if "from" in args else None
to = on if on else args["to"][0] if "to" in args else None
frm = frm or datetime.datetime.now().strftime('%Y-%m-%d')
to = to or datetime.datetime.now().strftime('%Y-%m-%d')
for time in frm, to:
try:
datetime.strptime(time, "%Y-%m-%d")
datetime.datetime.strptime(time, "%Y-%m-%d")
except:
re("400 Bad Request", [])
yield "<h1>400 Bad Request</h1>".encode()
@ -177,7 +177,7 @@ def application(env, re):
"""
for row in cur.fetchall():
output += " [ %s, %s ],\n" % (lat, lon)
output += " [ %s, %s ],\n" % (row["lat"], row["lon"])
output = "".join(output.rsplit(",", 1))