#!/usr/bin/env python # ############################################################################### # HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS # GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL # # 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. ''' from flask import Flask import ast, os app = Flask(__name__) dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) #dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) def get_data(): dash_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) tmp_bb = '' tmp_loc = '' tbl_hdr = ''' ''' tbl_ftr = '''
''' bb_hdr = '''

 Callsign 

 DMR ID 

 Bulletin 

 Local Time 

''' loc_hdr = '''

 Callsign 

 Latitude 

 Longitude 

 Local Time 

''' for e in dash_bb: tmp_bb = tmp_bb + '''  ''' + e['call'] + '''  ''' + str(e['dmr_id']) + '''  ''' + e['bulliten'] + '''   ''' + e['time'] + '''  ''' for e in dash_loc: tmp_loc = tmp_loc + '''  ''' + e['call'] + '''   ''' + str(e['lat']) + '''   ''' + str(e['lon']) + '''   ''' + e['time'] + '''  ''' return str('

Bulletin Board

' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr + str('

Positions Received

') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr) @app.route('/') def dash(): #return 'Hello, World!' return get_data()