diff options
| author | Yuval Adam <_@yuv.al> | 2020-09-28 19:08:12 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2020-09-28 19:08:12 +0300 |
| commit | aa685f4a2b7743ced2ceafc65538eb5457f5ee97 (patch) | |
| tree | 7d10fcae8ee166a433ca286d9f773be8b0f9f9bb | |
| parent | ca75913e447f37656ca516b235d27d8cf054e9f0 (diff) | |
Split passes endpoint
| -rw-r--r-- | iss/server.py | 13 | ||||
| -rw-r--r-- | iss/templates/base.html | 2 | ||||
| -rw-r--r-- | iss/templates/index.html | 38 | ||||
| -rw-r--r-- | iss/templates/passes.html | 43 |
4 files changed, 57 insertions, 39 deletions
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 @@ </head> <body class="bg-near-black near-white"> <div class="pa4 mw8 center"> - <h1 class="f1 moon-gray">ISS Pass Predictions</h1> + <a href="/" class="no-underline dim"><h1 class="f1 moon-gray">ISS Pass Predictions</h1></a> <p class="light-red">Upcoming passes of the <a href="https://en.wikipedia.org/wiki/International_Space_Station" class="link red dim">International Space Station</a> at your location over the next 10 days.</p> {% 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 %} -<table class="tl pa1 w-100"> - <tr class=" tc pa1 f3"> - <th colspan="1">Total</th> - <th colspan="2">Rise</th> - <th colspan="4">Culminate</th> - <th colspan="2">Set</th> - </tr> - <tr class="pa1 f4"> - <th>Date</th> - <th>Length</th> - <th>Time</th> - <th>Azimuth</th> - <th>Time</th> - <th>Azimuth</th> - <th>Elevation</th> - <th>Distance</th> - <th>Time</th> - <th>Azimuth</th> - </tr> - {% for date, preds in predictions.items() %} - {% set date_loop = loop %} - {% for pred in preds %} - <tr class="pa1 {{ date_loop.cycle('light-gray', 'light-silver') }}"> - {% if loop.first %}<td rowspan="{{ preds|length }}">{{ date }}</td>{% endif %} - <td>{{ pred.length }}</td> - <td>{{ pred.rise.time }}</td> - <td>{{ pred.rise.azimuth }} ({{ pred.rise.direction }})</td> - <td>{{ pred.culminate.time }}</td> - <td>{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }})</td> - <td>{{ pred.culminate.degrees }}</td> - <td>{{ pred.culminate.distance }}</td> - <td>{{ pred.set.time }}</td> - <td>{{ pred.set.azimuth }} ({{ pred.set.direction }}) </td> - </tr> - {% endfor %} - {% endfor %} - -</table> {% endblock %} diff --git a/iss/templates/passes.html b/iss/templates/passes.html new file mode 100644 index 0000000..e430c69 --- /dev/null +++ b/iss/templates/passes.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} + +{% block content %} +<p class="f3">Passes for {{ location.lat }}, {{ location.lng }}</p> +<table class="tl pa1 w-100"> + <tr class=" tc pa1 f3"> + <th colspan="1">Total</th> + <th colspan="2">Rise</th> + <th colspan="4">Culminate</th> + <th colspan="2">Set</th> + </tr> + <tr class="pa1 f4"> + <th>Date</th> + <th>Length</th> + <th>Time</th> + <th>Azimuth</th> + <th>Time</th> + <th>Azimuth</th> + <th>Elevation</th> + <th>Distance</th> + <th>Time</th> + <th>Azimuth</th> + </tr> + {% for date, preds in predictions.items() %} + {% set date_loop = loop %} + {% for pred in preds %} + <tr class="pa1 {{ date_loop.cycle('light-gray', 'light-silver') }}"> + {% if loop.first %}<td rowspan="{{ preds|length }}">{{ date }}</td>{% endif %} + <td>{{ pred.length }}</td> + <td>{{ pred.rise.time }}</td> + <td>{{ pred.rise.azimuth }} ({{ pred.rise.direction }})</td> + <td>{{ pred.culminate.time }}</td> + <td>{{ pred.culminate.azimuth }} ({{ pred.culminate.direction }})</td> + <td>{{ pred.culminate.degrees }}</td> + <td>{{ pred.culminate.distance }}</td> + <td>{{ pred.set.time }}</td> + <td>{{ pred.set.azimuth }} ({{ pred.set.direction }}) </td> + </tr> + {% endfor %} + {% endfor %} + +</table> +{% endblock %} |
