Show relative time.
This commit is contained in:
parent
acdee84d3e
commit
50e8324786
10
api_app.py
10
api_app.py
|
@ -4,6 +4,7 @@ from datetime import date, timedelta
|
|||
import configparser
|
||||
import csv
|
||||
import datetime
|
||||
import timeago
|
||||
import ast
|
||||
import glob
|
||||
import json, operator
|
||||
|
@ -118,7 +119,11 @@ def index():
|
|||
|
||||
# Get list of recent packets using API
|
||||
# TODO use relative path
|
||||
response = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/packets").text)['data']
|
||||
frames = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/packets").text)['data']
|
||||
for frame in frames:
|
||||
if frame['created'] != None:
|
||||
frame['time_ago'] = timeago.format(frame['created_unix'], datetime.datetime.now())
|
||||
|
||||
|
||||
# Play with function to create station list
|
||||
#stations = select_all_stations(get_db_connection())
|
||||
|
@ -129,12 +134,13 @@ def index():
|
|||
for station in stations:
|
||||
if station['last_heard_unix'] != None:
|
||||
station['last_heard'] = datetime.datetime.utcfromtimestamp(station['last_heard_unix'])
|
||||
station['time_ago'] = timeago.format(station['last_heard_unix'], datetime.datetime.now())
|
||||
|
||||
return render_template('index.html',
|
||||
station_call = config['Settings']['station_call'],
|
||||
station_lat = config['Settings']['station_lat'],
|
||||
station_lon = config['Settings']['station_lon'],
|
||||
frames = response,
|
||||
frames = frames,
|
||||
stations = stations)
|
||||
|
||||
class Packets(Resource):
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<th> object_name </th>
|
||||
<th> raw </th>
|
||||
<th> created (utc) </th>
|
||||
<th> relative </th>
|
||||
<th> more </th>
|
||||
</tr>
|
||||
{% for i in frames %}
|
||||
|
@ -29,6 +30,7 @@
|
|||
<td> {{ i['object_name'] }} </td>
|
||||
<td> {{ i['raw'] }} </td>
|
||||
<td> {{ i['created'] }} </td>
|
||||
<td> {{ i['time_ago'] }} </td>
|
||||
<td> <a href="https://digi.w1cdn.net/aprs_api/packets?id={{ i['id'] }}">query</a>,
|
||||
<a href="https://aprs.fi/#!mt=roadmap&z=12&call=a%2F{{ i['from'] }}">aprs.fi</a></td>
|
||||
</tr>
|
||||
|
@ -40,6 +42,7 @@
|
|||
<tr>
|
||||
<th> from </th>
|
||||
<th> last heard (utc) </th>
|
||||
<th> relative </th>
|
||||
<th> count </th>
|
||||
<th> more </th>
|
||||
</tr>
|
||||
|
@ -47,6 +50,7 @@
|
|||
<tr>
|
||||
<td> <a href="https://digi.w1cdn.net/aprs_api/packets?from={{ i['from'] }}">{{ i['from'] }}</a> </td>
|
||||
<td> {{ i['last_heard'] }} </td>
|
||||
<td> {{ i['time_ago'] }} </td>
|
||||
<td> {{ i['count']}} </td>
|
||||
<td> <a href="https://aprs.fi/#!mt=roadmap&z=12&call=a%2F{{ i['from'] }}">aprs.fi</a></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue
Block a user