From aa685f4a2b7743ced2ceafc65538eb5457f5ee97 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Mon, 28 Sep 2020 19:08:12 +0300 Subject: Split passes endpoint --- iss/server.py | 13 +++++++++++++ iss/templates/base.html | 2 +- iss/templates/index.html | 38 -------------------------------------- iss/templates/passes.html | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 39 deletions(-) create mode 100644 iss/templates/passes.html (limited to 'iss') diff --git a/iss/server.py b/iss/server.py index d03cec4..f014d7f 100644 --- a/iss/server.py +++ b/iss/server.py @@ -17,3 +17,16 @@ async def home(request: Request): return templates.TemplateResponse( "index.html", {"request": request, "predictions": preds} ) + + +@app.get("/passes/{lat}/{lng}") +async def passes(request: Request, lat: float, lng: float): + preds = Predictions(lat, lng, altitude=0, days=5).get_grouped_predictions() + return templates.TemplateResponse( + "passes.html", + { + "request": request, + "predictions": preds, + "location": {"lat": lat, "lng": lng}, + }, + ) diff --git a/iss/templates/base.html b/iss/templates/base.html index eb9767d..e7a0cd7 100644 --- a/iss/templates/base.html +++ b/iss/templates/base.html @@ -12,7 +12,7 @@
Upcoming passes of the International Space Station at your location over the next 10 days.
{% block content %} diff --git a/iss/templates/index.html b/iss/templates/index.html index 37b5f40..e48212a 100644 --- a/iss/templates/index.html +++ b/iss/templates/index.html @@ -1,42 +1,4 @@ {% extends "base.html" %} {% block content %} -| Total | -Rise | -Culminate | -Set | -||||||
|---|---|---|---|---|---|---|---|---|---|
| Date | -Length | -Time | -Azimuth | -Time | -Azimuth | -Elevation | -Distance | -Time | -Azimuth | -
| {{ date }} | {% endif %} -{{ pred.length }} | -{{ pred.rise.time }} | -{{ pred.rise.azimuth }} ({{ pred.rise.direction }}) | -{{ pred.culminate.time }} | -{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }}) | -{{ pred.culminate.degrees }} | -{{ pred.culminate.distance }} | -{{ pred.set.time }} | -{{ pred.set.azimuth }} ({{ pred.set.direction }}) | -
Passes for {{ location.lat }}, {{ location.lng }}
+| Total | +Rise | +Culminate | +Set | +||||||
|---|---|---|---|---|---|---|---|---|---|
| Date | +Length | +Time | +Azimuth | +Time | +Azimuth | +Elevation | +Distance | +Time | +Azimuth | +
| {{ date }} | {% endif %} +{{ pred.length }} | +{{ pred.rise.time }} | +{{ pred.rise.azimuth }} ({{ pred.rise.direction }}) | +{{ pred.culminate.time }} | +{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }}) | +{{ pred.culminate.degrees }} | +{{ pred.culminate.distance }} | +{{ pred.set.time }} | +{{ pred.set.azimuth }} ({{ pred.set.direction }}) | +