def deviceQuery(): ''' This function shows an empty page with IP query field and button (GET) or a list of queried devices with associated session information (POST). ''' try: if request.method == 'GET': return render_template('deviceQuery.html', post_request_done=False, ip_address='', relevant_sessions={}) elif request.method == 'POST': ip_address = request.form.get("ip_address") relevant_sessions = backend.get_device_auth_sessions(ip_address) propagate_backend_exception(relevant_sessions) return render_template('deviceQuery.html', post_request_done=True, ip_address=ip_address, relevant_sessions=relevant_sessions) except Exception as e: print(e) return render_template('deviceQuery.html', error=True, errorcode=e)
def deviceList(): ''' This function will show all NAD devices in a table (GET request) and redirect to the specific query page of a device (POST request). The redirection can be manually triggered by a "Query Device" link in each table row and thereby for each NAD device. ''' if type(session.get('logged_in')) == int and session.get('logged_in') > int(time()): session['logged_in'] = int(time()) + backend.timeout print(f"Login for {session['username']} extended until: {ctime(session['logged_in'])}") try: if request.method == 'GET': device_list = backend.get_all_NADs() propagate_backend_exception(device_list) return render_template('deviceList.html', device_list=device_list) elif request.method == 'POST': ip_address = request.form.get("ip_address") relevant_sessions = backend.get_device_auth_sessions(ip_address) propagate_backend_exception(relevant_sessions) print(relevant_sessions) print(ip_address) return render_template('deviceQuery.html', post_request_done=True, ip_address=ip_address, relevant_sessions=relevant_sessions) except Exception as e: print(e) return render_template('deviceList.html', error=True, errorcode=e, reloadlink='/') else: print("First you need to login") return redirect(url_for('login'))
def index(): ''' This function will show all NAD devices in a table (GET request) and redirect to the specific query page of a device (POST request). The redirection can be manually triggered by a "Query Device" link in each table row and thereby for each NAD device. ''' try: if request.method == 'GET': device_list = backend.get_all_NADs() propagate_backend_exception(device_list) return render_template('deviceList.html', device_list=device_list) elif request.method == 'POST': ip_address = request.form.get("ip_address") relevant_sessions = backend.get_device_auth_sessions(ip_address) propagate_backend_exception(relevant_sessions) print(relevant_sessions) print(ip_address) return render_template('deviceQuery.html', post_request_done=True, ip_address=ip_address, relevant_sessions=relevant_sessions) except Exception as e: print(e) return render_template('deviceList.html', error=True, errorcode=e, reloadlink='/')
def deviceQuery(): ''' This function shows an empty page with IP query field and button (GET) or a list of queried devices with associated session information (POST). ''' if type(session.get('logged_in')) == int and session.get('logged_in') > int(time()): session['logged_in'] = int(time()) + backend.timeout print(f"Login for {session['username']} extended until: {ctime(session['logged_in'])}") try: if request.method == 'GET': return render_template('deviceQuery.html', post_request_done=False, ip_address='', relevant_sessions={}) elif request.method == 'POST': ip_address = request.form.get("ip_address") relevant_sessions = backend.get_device_auth_sessions(ip_address) propagate_backend_exception(relevant_sessions) return render_template('deviceQuery.html', post_request_done=True, ip_address=ip_address, relevant_sessions=relevant_sessions) except Exception as e: print(e) return render_template('deviceQuery.html', error=True, errorcode=e) else: print("First you need to login") return redirect(url_for('login'))