Show relative time.
This commit is contained in:
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):
|
||||
|
Reference in New Issue
Block a user