fix wrong app.py las commit
This commit is contained in:
		
							parent
							
								
									901b9ee933
								
							
						
					
					
						commit
						c123b94618
					
				
							
								
								
									
										297
									
								
								web/app.py
									
									
									
									
									
								
							
							
						
						
									
										297
									
								
								web/app.py
									
									
									
									
									
								
							@ -47,61 +47,58 @@ from gen_script_template import gen_script
 | 
				
			|||||||
import os, ast
 | 
					import os, ast
 | 
				
			||||||
##import hb_config
 | 
					##import hb_config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from hws.misc_functions import *
 | 
					 | 
				
			||||||
from hws.views import *
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
script_links = {}
 | 
					script_links = {}
 | 
				
			||||||
active_tgs = {}
 | 
					active_tgs = {}
 | 
				
			||||||
ping_list = {}
 | 
					ping_list = {}
 | 
				
			||||||
peer_locations = {}
 | 
					peer_locations = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Query radioid.net for list of IDs
 | 
					# Query radioid.net for list of IDs
 | 
				
			||||||
##def get_ids(callsign):
 | 
					def get_ids(callsign):
 | 
				
			||||||
##    try:
 | 
					    try:
 | 
				
			||||||
##        url = "https://www.radioid.net"
 | 
					        url = "https://www.radioid.net"
 | 
				
			||||||
##        response = requests.get(url+"/api/dmr/user/?callsign=" + callsign)
 | 
					        response = requests.get(url+"/api/dmr/user/?callsign=" + callsign)
 | 
				
			||||||
##        result = response.json()
 | 
					        result = response.json()
 | 
				
			||||||
####        print(result)
 | 
					##        print(result)
 | 
				
			||||||
##    #        id_list = []
 | 
					    #        id_list = []
 | 
				
			||||||
##        id_list = {}
 | 
					        id_list = {}
 | 
				
			||||||
##        f_name = result['results'][0]['fname']
 | 
					        f_name = result['results'][0]['fname']
 | 
				
			||||||
##        l_name = result['results'][0]['surname']
 | 
					        l_name = result['results'][0]['surname']
 | 
				
			||||||
##        try:
 | 
					        try:
 | 
				
			||||||
##            city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country'])
 | 
					            city = str(result['results'][0]['city'] + ', ' + result['results'][0]['state'] + ', ' + result['results'][0]['country'])
 | 
				
			||||||
##        except:
 | 
					        except:
 | 
				
			||||||
##            city = result['results'][0]['country']
 | 
					            city = result['results'][0]['country']
 | 
				
			||||||
##        for i in result['results']:
 | 
					        for i in result['results']:
 | 
				
			||||||
##             id_list[i['id']] = 0
 | 
					             id_list[i['id']] = 0
 | 
				
			||||||
##        return str([id_list, f_name, l_name, city])
 | 
					        return str([id_list, f_name, l_name, city])
 | 
				
			||||||
##    except:
 | 
					    except:
 | 
				
			||||||
##        return str([{}, '', '', ''])
 | 
					        return str([{}, '', '', ''])
 | 
				
			||||||
## 
 | 
					 
 | 
				
			||||||
##
 | 
					
 | 
				
			||||||
### Return string in NATO phonetics
 | 
					# Return string in NATO phonetics
 | 
				
			||||||
##def convert_nato(string):
 | 
					def convert_nato(string):
 | 
				
			||||||
##    d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA',
 | 
					    d_nato = { 'A': 'ALPHA', 'B': 'BRAVO', 'C': 'CHARLIE', 'D': 'DELTA',
 | 
				
			||||||
##          'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL',
 | 
					          'E': 'ECHO', 'F': 'FOXTROT', 'G': 'GOLF', 'H': 'HOTEL',
 | 
				
			||||||
##          'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA',
 | 
					          'I': 'INDIA', 'J': 'JULIETT','K': 'KILO', 'L': 'LIMA',
 | 
				
			||||||
##         'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA',
 | 
					         'M': 'MIKE', 'N': 'NOVEMBER','O': 'OSCAR', 'P': 'PAPA',
 | 
				
			||||||
##         'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO',
 | 
					         'Q': 'QUEBEC', 'R': 'ROMEO', 'S': 'SIERRA', 'T': 'TANGO',
 | 
				
			||||||
##         'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY',
 | 
					         'U': 'UNIFORM', 'V': 'VICTOR', 'W': 'WHISKEY', 'X': 'X-RAY',
 | 
				
			||||||
##         'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)',
 | 
					         'Y': 'YANKEE', 'Z': 'ZULU', '0': 'zero(0)', '1': 'one(1)',
 | 
				
			||||||
##         '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)',
 | 
					         '2': 'two(2)', '3': 'three(3)', '4': 'four(4)', '5': 'five(5)',
 | 
				
			||||||
##         '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)',
 | 
					         '6': 'six(6)', '7': 'seven(7)', '8': 'eight(8)', '9': 'nine(9)',
 | 
				
			||||||
##         'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta',
 | 
					         'a': 'alpha', 'b': 'bravo', 'c': 'charlie', 'd': 'delta',
 | 
				
			||||||
##         'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel',
 | 
					         'e': 'echo', 'f': 'foxtrot', 'g': 'golf', 'h': 'hotel',
 | 
				
			||||||
##         'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima',
 | 
					         'i': 'india', 'j': 'juliett','k': 'kilo', 'l': 'lima',
 | 
				
			||||||
##         'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa',
 | 
					         'm': 'mike', 'n': 'november','o': 'oscar', 'p': 'papa',
 | 
				
			||||||
##         'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango',
 | 
					         'q': 'quebec', 'r': 'romeo', 's': 'sierra', 't': 'tango',
 | 
				
			||||||
##         'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray',
 | 
					         'u': 'uniform', 'v': 'victor', 'w': 'whiskey', 'x': 'x-ray',
 | 
				
			||||||
##         'y': 'yankee', 'z': 'Zulu'}
 | 
					         'y': 'yankee', 'z': 'Zulu'}
 | 
				
			||||||
##    ns = ''
 | 
					    ns = ''
 | 
				
			||||||
##    for c in string:
 | 
					    for c in string:
 | 
				
			||||||
##        try:
 | 
					        try:
 | 
				
			||||||
##            ns = ns + d_nato[c] + ' '
 | 
					            ns = ns + d_nato[c] + ' '
 | 
				
			||||||
##        except:
 | 
					        except:
 | 
				
			||||||
##            ns = ns + c + ' '
 | 
					            ns = ns + c + ' '
 | 
				
			||||||
##    return ns
 | 
					    return ns
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Class-based application configuration
 | 
					# Class-based application configuration
 | 
				
			||||||
class ConfigClass(object):
 | 
					class ConfigClass(object):
 | 
				
			||||||
@ -665,108 +662,108 @@ def create_app():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        db.session.commit()
 | 
					        db.session.commit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
##    # The Home page is accessible to anyone
 | 
					    # The Home page is accessible to anyone
 | 
				
			||||||
##    @app.route('/')
 | 
					    @app.route('/')
 | 
				
			||||||
##    def home_page():
 | 
					    def home_page():
 | 
				
			||||||
##        home_text = Misc.query.filter_by(field_1='home_page').first()
 | 
					        home_text = Misc.query.filter_by(field_1='home_page').first()
 | 
				
			||||||
##        #content = Markup('<strong>Index</strong>')
 | 
					        #content = Markup('<strong>Index</strong>')
 | 
				
			||||||
##        try:
 | 
					        try:
 | 
				
			||||||
##            l_news = News.query.order_by(News.time.desc()).first()
 | 
					            l_news = News.query.order_by(News.time.desc()).first()
 | 
				
			||||||
##            content = '''
 | 
					            content = '''
 | 
				
			||||||
##
 | 
					
 | 
				
			||||||
##<div class="well well-sm" style="text-align: center;"><h3>''' + l_news.subject + '''</h3>
 | 
					<div class="well well-sm" style="text-align: center;"><h3>''' + l_news.subject + '''</h3>
 | 
				
			||||||
##<hr />
 | 
					<hr />
 | 
				
			||||||
##<p> </p>
 | 
					<p> </p>
 | 
				
			||||||
##<strong>''' + l_news.date + '''</strong> - <a href="/news/''' + str(l_news.id) + '''"><button type="button" class="btn btn-primary">Link</button></a>
 | 
					<strong>''' + l_news.date + '''</strong> - <a href="/news/''' + str(l_news.id) + '''"><button type="button" class="btn btn-primary">Link</button></a>
 | 
				
			||||||
##<p> </p>
 | 
					<p> </p>
 | 
				
			||||||
##
 | 
					
 | 
				
			||||||
##<hr />
 | 
					<hr />
 | 
				
			||||||
##<div class="well well-sm" style="max-width:900px; word-wrap:break-word;">
 | 
					<div class="well well-sm" style="max-width:900px; word-wrap:break-word;">
 | 
				
			||||||
##''' + l_news.text + '''
 | 
					''' + l_news.text + '''
 | 
				
			||||||
##</div>
 | 
					</div>
 | 
				
			||||||
##</div>
 | 
					</div>
 | 
				
			||||||
##  
 | 
					  
 | 
				
			||||||
##  </div>
 | 
					  </div>
 | 
				
			||||||
##    '''
 | 
					    '''
 | 
				
			||||||
##        except:
 | 
					        except:
 | 
				
			||||||
##            content = ''
 | 
					            content = ''
 | 
				
			||||||
##        return render_template('index.html', news = Markup(content), content_block = Markup(home_text.field_2))
 | 
					        return render_template('index.html', news = Markup(content), content_block = Markup(home_text.field_2))
 | 
				
			||||||
##
 | 
					
 | 
				
			||||||
##    @app.route('/tos')
 | 
					    @app.route('/tos')
 | 
				
			||||||
##    def tos_page():
 | 
					    def tos_page():
 | 
				
			||||||
##        tos_text = Misc.query.filter_by(field_1='terms_of_service').first()
 | 
					        tos_text = Misc.query.filter_by(field_1='terms_of_service').first()
 | 
				
			||||||
##        content = tos_text.field_2
 | 
					        content = tos_text.field_2
 | 
				
			||||||
##        
 | 
					        
 | 
				
			||||||
##        return render_template('flask_user_layout.html', markup_content = Markup(content))
 | 
					        return render_template('flask_user_layout.html', markup_content = Markup(content))
 | 
				
			||||||
##
 | 
					
 | 
				
			||||||
##    @app.route('/map')
 | 
					    @app.route('/map')
 | 
				
			||||||
##    @login_required
 | 
					    @login_required
 | 
				
			||||||
##    def map_page():
 | 
					    def map_page():
 | 
				
			||||||
##        print(peer_locations)
 | 
					        print(peer_locations)
 | 
				
			||||||
##        f_map = folium.Map(location=center_map, zoom_start=map_zoom)
 | 
					        f_map = folium.Map(location=center_map, zoom_start=map_zoom)
 | 
				
			||||||
##        for l in peer_locations.items():
 | 
					        for l in peer_locations.items():
 | 
				
			||||||
####            folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
 | 
					 | 
				
			||||||
####<div class="panel panel-default">
 | 
					 | 
				
			||||||
####  <div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
 | 
					 | 
				
			||||||
####  <div class="panel-body">
 | 
					 | 
				
			||||||
####  ''' + l[1][5] + '''
 | 
					 | 
				
			||||||
####  <hr />
 | 
					 | 
				
			||||||
####  ''' + l[1][1] + ''', ''' + l[1][2] + '''
 | 
					 | 
				
			||||||
####  <hr />
 | 
					 | 
				
			||||||
####  ''' + l[1][3] + '''
 | 
					 | 
				
			||||||
####  <hr />
 | 
					 | 
				
			||||||
####  ''' + l[1][4] + '''
 | 
					 | 
				
			||||||
####  <hr />
 | 
					 | 
				
			||||||
####  ''' + l[1][6] + '''
 | 
					 | 
				
			||||||
####    </div>
 | 
					 | 
				
			||||||
####</div>
 | 
					 | 
				
			||||||
####         ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
 | 
					 | 
				
			||||||
##
 | 
					 | 
				
			||||||
##            folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
 | 
					##            folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
 | 
				
			||||||
##<table border="1">
 | 
					##<div class="panel panel-default">
 | 
				
			||||||
##<tbody>
 | 
					##  <div class="panel-heading" style="text-align: center;"><h4>''' + l[1][0] + '''</h4></div>
 | 
				
			||||||
##<tr>
 | 
					##  <div class="panel-body">
 | 
				
			||||||
##<td> <strong><h4>''' + l[1][0] + '''</strong></h4> </td>
 | 
					##  ''' + l[1][5] + '''
 | 
				
			||||||
##</tr>
 | 
					##  <hr />
 | 
				
			||||||
##</tbody>
 | 
					##  ''' + l[1][1] + ''', ''' + l[1][2] + '''
 | 
				
			||||||
##</table>
 | 
					##  <hr />
 | 
				
			||||||
##<table border="1">
 | 
					##  ''' + l[1][3] + '''
 | 
				
			||||||
##<tbody>
 | 
					##  <hr />
 | 
				
			||||||
##<tr>
 | 
					##  ''' + l[1][4] + '''
 | 
				
			||||||
##<td style="width: 64.4667px;"><strong>DMR ID:</strong></td>
 | 
					##  <hr />
 | 
				
			||||||
##<td> ''' + str(l[0]) + ''' </td>
 | 
					##  ''' + l[1][6] + '''
 | 
				
			||||||
##</tr>
 | 
					##    </div>
 | 
				
			||||||
##<tr>
 | 
					##</div>
 | 
				
			||||||
##<td style="width: 64.4667px;"><strong>Location:</strong></td>
 | 
					 | 
				
			||||||
##<td> ''' + l[1][5] + ''' </td>
 | 
					 | 
				
			||||||
##</tr>
 | 
					 | 
				
			||||||
##<tr>
 | 
					 | 
				
			||||||
##<td style="width: 64.4667px;"><strong>Lat, Lon:</strong></td>
 | 
					 | 
				
			||||||
##<td> ''' + l[1][1] + ''', ''' + l[1][2] + ''' </td>
 | 
					 | 
				
			||||||
##</tr>
 | 
					 | 
				
			||||||
##<tr>
 | 
					 | 
				
			||||||
##<td style="width: 64.4667px;"><strong>Description:</strong></td>
 | 
					 | 
				
			||||||
##<td> ''' + l[1][4] + ''' </td>
 | 
					 | 
				
			||||||
##</tr>
 | 
					 | 
				
			||||||
##<tr>
 | 
					 | 
				
			||||||
##<td style="width: 64.4667px;"><p><strong>URL:</strong></p>
 | 
					 | 
				
			||||||
##</td>
 | 
					 | 
				
			||||||
##<td><a href="''' + l[1][3] + '''"> ''' + l[1][3] + ''' </a></td>
 | 
					 | 
				
			||||||
##</tr>
 | 
					 | 
				
			||||||
##<tr>
 | 
					 | 
				
			||||||
##<td style="width: 64.4667px;"><strong>Device:</strong></td>
 | 
					 | 
				
			||||||
##<td> ''' + l[1][6] + ''' </td>
 | 
					 | 
				
			||||||
##</tr>
 | 
					 | 
				
			||||||
##</tbody>
 | 
					 | 
				
			||||||
##</table>
 | 
					 | 
				
			||||||
##         ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
 | 
					##         ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
 | 
				
			||||||
##        content = f_map._repr_html_()
 | 
					
 | 
				
			||||||
##       
 | 
					            folium.Marker([float(l[1][1]), float(l[1][2])], popup='''
 | 
				
			||||||
##        return render_template('map.html', markup_content = Markup(content))
 | 
					<table border="1">
 | 
				
			||||||
##    
 | 
					<tbody>
 | 
				
			||||||
##    @app.route('/help')
 | 
					<tr>
 | 
				
			||||||
##    def help_page():
 | 
					<td> <strong><h4>''' + l[1][0] + '''</strong></h4> </td>
 | 
				
			||||||
##        return render_template('help.html')
 | 
					</tr>
 | 
				
			||||||
 | 
					</tbody>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					<table border="1">
 | 
				
			||||||
 | 
					<tbody>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><strong>DMR ID:</strong></td>
 | 
				
			||||||
 | 
					<td> ''' + str(l[0]) + ''' </td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><strong>Location:</strong></td>
 | 
				
			||||||
 | 
					<td> ''' + l[1][5] + ''' </td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><strong>Lat, Lon:</strong></td>
 | 
				
			||||||
 | 
					<td> ''' + l[1][1] + ''', ''' + l[1][2] + ''' </td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><strong>Description:</strong></td>
 | 
				
			||||||
 | 
					<td> ''' + l[1][4] + ''' </td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><p><strong>URL:</strong></p>
 | 
				
			||||||
 | 
					</td>
 | 
				
			||||||
 | 
					<td><a href="''' + l[1][3] + '''"> ''' + l[1][3] + ''' </a></td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr>
 | 
				
			||||||
 | 
					<td style="width: 64.4667px;"><strong>Device:</strong></td>
 | 
				
			||||||
 | 
					<td> ''' + l[1][6] + ''' </td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					</tbody>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					         ''', icon=folium.Icon(color="red", icon="record"), tooltip='<strong>' + l[1][0] + '</strong>').add_to(f_map)
 | 
				
			||||||
 | 
					        content = f_map._repr_html_()
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        return render_template('map.html', markup_content = Markup(content))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @app.route('/help')
 | 
				
			||||||
 | 
					    def help_page():
 | 
				
			||||||
 | 
					        return render_template('help.html')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @app.route('/generate_passphrase/pi-star', methods = ['GET'])
 | 
					    @app.route('/generate_passphrase/pi-star', methods = ['GET'])
 | 
				
			||||||
    @login_required
 | 
					    @login_required
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user