Add status page #30
20
api_app.py
20
api_app.py
|
@ -69,6 +69,17 @@ def select_all_frames(conn):
|
|||
rows = cur.fetchall()
|
||||
return rows
|
||||
|
||||
def unique_stations(conn):
|
||||
"""
|
||||
Query all rows in the frames table
|
||||
:param conn: the Connection object
|
||||
:return:
|
||||
"""
|
||||
cur = conn.cursor()
|
||||
cur.execute('SELECT *, MAX(id) FROM frames GROUP BY "from" ORDER BY MAX(id) DESC')
|
||||
rows = cur.fetchall()
|
||||
return rows
|
||||
|
||||
def select_frames(conn, n, url_params):
|
||||
|
||||
# Should pass this a dict of fields and values (request.args)
|
||||
|
@ -96,11 +107,18 @@ 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']
|
||||
|
||||
# Play with function to create station list
|
||||
stations = unique_stations(get_db_connection())
|
||||
print(stations)
|
||||
|
||||
|
||||
return render_template('index.html',
|
||||
station_call = config['Settings']['station_call'],
|
||||
station_lat = config['Settings']['station_lat'],
|
||||
station_lon = config['Settings']['station_lon'],
|
||||
d = response)
|
||||
frames = response,
|
||||
stations = stations)
|
||||
|
||||
class Packets(Resource):
|
||||
def get(self):
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<th> created (utc) </th>
|
||||
<th> more </th>
|
||||
</tr>
|
||||
{% for i in d %}
|
||||
{% for i in frames %}
|
||||
<tr>
|
||||
<td> <a href="https://digi.w1cdn.net/aprs_api/packets?from={{ i['from'] }}">{{ i['from'] }}</a> </td>
|
||||
<td> {{ i['object_name'] }} </td>
|
||||
|
@ -37,6 +37,17 @@
|
|||
<h2> Recent Stations </h2>
|
||||
Coming soon, see <a href="https://amiok.net/gitea/W1CDN/aprs_tool/issues/16">https://amiok.net/gitea/W1CDN/aprs_tool/issues/16</a>.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th> raw </th>
|
||||
</tr>
|
||||
{% for i in stations %}
|
||||
<tr>
|
||||
<td> {{ i['raw'] }} </td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h2> Help </h2>
|
||||
This is a work in progress. See <a href="https://amiok.net/gitea/W1CDN/aprs_tool">https://amiok.net/gitea/W1CDN/aprs_tool</a> for usage.
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user