2020-12-29 23:36:07 -05:00
|
|
|
###############################################################################
|
|
|
|
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
|
|
|
|
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
'''
|
|
|
|
This is a web dashboard for the GPS/Data application.
|
|
|
|
'''
|
|
|
|
|
2020-12-30 12:10:23 -05:00
|
|
|
from flask import Flask, render_template
|
2020-12-29 23:36:07 -05:00
|
|
|
import ast, os
|
2020-12-30 12:10:23 -05:00
|
|
|
from dashboard_settings import *
|
2020-12-29 23:36:07 -05:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
2020-12-30 12:10:23 -05:00
|
|
|
|
|
|
|
tbl_hdr = '''
|
2020-12-29 23:36:07 -05:00
|
|
|
<table style="border-color: black; margin-left: auto; margin-right: auto;" border="2" cellspacing="6" cellpadding="2"><tbody>
|
|
|
|
'''
|
2020-12-30 12:10:23 -05:00
|
|
|
tbl_ftr = '''
|
2020-12-29 23:36:07 -05:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
'''
|
2020-12-30 12:10:23 -05:00
|
|
|
|
|
|
|
def get_loc_data():
|
|
|
|
try:
|
|
|
|
dash_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read())
|
|
|
|
tmp_loc = ''
|
|
|
|
loc_hdr = '''
|
|
|
|
<tr>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2><strong> Callsign </strong></h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>Latitude</strong> </h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>Longitude</strong> </h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>Local Time</strong> </h2>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
'''
|
|
|
|
for e in dash_loc:
|
|
|
|
tmp_loc = tmp_loc + '''<tr>
|
|
|
|
<td style="text-align: center;"><a href="https://aprs.fi/''' + e['call'] + '''"><strong>''' + e['call'] + '''</strong></a></td>
|
|
|
|
<td style="text-align: center;"><strong> ''' + str(e['lat']) + ''' </strong></td>
|
|
|
|
<td style="text-align: center;"><strong> ''' + str(e['lon']) + ''' </strong></td>
|
|
|
|
<td style="text-align: center;"> ''' + e['time'] + ''' </td>
|
|
|
|
</tr>'''
|
|
|
|
return str(str('<h1 style="text-align: center;">Positions Received</h1>') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr)
|
|
|
|
except:
|
|
|
|
return str('<h1 style="text-align: center;">No data</h1>')
|
|
|
|
|
|
|
|
|
|
|
|
def get_bb_data():
|
|
|
|
try:
|
|
|
|
dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read())
|
|
|
|
tmp_bb = ''
|
|
|
|
|
|
|
|
bb_hdr = '''
|
|
|
|
<tr>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2><strong> Callsign </strong></h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>DMR ID</strong> </h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>Bulletin</strong> </h2>
|
|
|
|
</td>
|
|
|
|
<td style="text-align: center;">
|
|
|
|
<h2> <strong>Local Time</strong> </h2>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
'''
|
|
|
|
|
|
|
|
for e in dash_bb:
|
|
|
|
tmp_bb = tmp_bb + '''<tr>
|
|
|
|
<td style="text-align: center;"><strong> ''' + e['call'] + ''' </strong></td>
|
|
|
|
<td style="text-align: center;">''' + str(e['dmr_id']) + '''</td>
|
|
|
|
<td style="text-align: center;"><strong> ''' + e['bulliten'] + ''' </strong></td>
|
|
|
|
<td style="text-align: center;"> ''' + e['time'] + ''' </td>
|
|
|
|
</tr>'''
|
|
|
|
|
|
|
|
return str('<h1 style="text-align: center;">Bulletin Board</h1>' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr)
|
|
|
|
except:
|
|
|
|
return str('<h1 style="text-align: center;">No data</h1>')
|
2020-12-29 23:36:07 -05:00
|
|
|
|
|
|
|
@app.route('/')
|
2020-12-30 12:10:23 -05:00
|
|
|
def index():
|
|
|
|
#return get_data()
|
2021-01-01 17:09:14 -05:00
|
|
|
return render_template('index.html', title = dashboard_title, logo = logo, description = description)
|
2020-12-30 12:10:23 -05:00
|
|
|
@app.route('/bulletin_board')
|
|
|
|
def dash_bb():
|
|
|
|
return get_bb_data()
|
|
|
|
#return render_template('index.html', data = str(get_data()))
|
|
|
|
@app.route('/positions')
|
|
|
|
def dash_loc():
|
|
|
|
return get_loc_data()
|
|
|
|
#return render_template('index.html', data = str(get_data()))
|
2020-12-30 12:35:25 -05:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-12-30 19:41:51 -05:00
|
|
|
app.run(debug = True, port=dash_port, host=dash_host)
|