Add Zugradar
This commit is contained in:
parent
d3256e0387
commit
cec2eca235
|
@ -1,3 +1,4 @@
|
||||||
from classes.connection import Connection
|
from classes.connection import Connection
|
||||||
from classes.station import Station
|
from classes.station import Station
|
||||||
from classes.service import Service
|
from classes.service import Service
|
||||||
|
from classes.train import Train
|
||||||
|
|
16
main.py
16
main.py
|
@ -5,6 +5,7 @@ import pytz
|
||||||
import workers.conn
|
import workers.conn
|
||||||
import workers.val
|
import workers.val
|
||||||
import workers.closest
|
import workers.closest
|
||||||
|
import workers.radar
|
||||||
|
|
||||||
def application(env, re):
|
def application(env, re):
|
||||||
if env["REQUEST_METHOD"] == "POST":
|
if env["REQUEST_METHOD"] == "POST":
|
||||||
|
@ -184,6 +185,21 @@ def application(env, re):
|
||||||
yield output.encode()
|
yield output.encode()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
elif rtype.lower() in ["radar", "live"]:
|
||||||
|
trains = args["train"] if "train" in args else None
|
||||||
|
try:
|
||||||
|
output = workers.radar.worker(trains, json)
|
||||||
|
except Exception as e:
|
||||||
|
re("500 Internal Server Error", [])
|
||||||
|
yield "<h1>500 Internal Server Error</h1>".encode()
|
||||||
|
if "debug" in args:
|
||||||
|
yield e.encode()
|
||||||
|
return
|
||||||
|
|
||||||
|
re("200 OK", [("Content-Type", "application/json" if json else "text/xml")])
|
||||||
|
yield output.encode()
|
||||||
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
re("400 Bad Request", [])
|
re("400 Bad Request", [])
|
||||||
yield "<h1>400 Bad Request</h1>".encode()
|
yield "<h1>400 Bad Request</h1>".encode()
|
||||||
|
|
Loading…
Reference in a new issue