<div id="symbol_space"> <img src="//localhost/assign_five/5Cubes2.png" height="150px" width="150px"/> </div> </div>""") bool = True # numeric = int(user_val) if user_val != None: for abc in user_val: if abc.isdigit() == False: bool = False # print(abc) # if user_val != None and type(user_val) != int: if user_val != None and bool: val = get_area_by_id(user_val) if val == None: #lines 44-49 will detect if a user has submitted a value which can't be found within the database a = get_all_areas() print("<div id=\"error_page1\"><strong>ERROR: User entered an ID which was not found!</strong></br>Select an Area</br><form method=\"get\" action=\"/cgi-bin/location_table.py\"><select name=\"area_id\" size=\"5\"></div>") for x in a: print("<option value=\"" + str(x['area_id']) + "\">" + x['name'] + "</option>") print("</select></br><input id=\"sButton\" type=\"submit\" value=\"Submit\"></form></div></div></body></html>") else: # print("test", val) for a in val: print("<div id=\"page_body2\">Location Information for the " + a['name'] + " area </br></br>") print("<form method =\"get\" action=\"/cgi-bin/measurement_table.py\"><table class=\"grid\"><th class=\"grid\">Select</th><th class=\"grid\">ID</th><th class=\"grid\">Name</th><th class=\"grid\">Altitude</th>") for x in get_locations_for_area(user_val): # print("<tr> <td><input type=\"radio\" value=\"" + x['name'] + "\" name=\"" + x['name'] + "\"></td> <td>" + str(x['location_id']) + " </td> <td>" + x['name'] + " </td> <td>" + str(x['altitude']) + " </td> </tr>")
"""); return tableHeaderRowString # ------------------------------------| CGI|---------------------------------------------- form = cgi.FieldStorage() try: formAreaID = form.getvalue('area_id') if formAreaID is None: printErrorMSG('NoneType') elif isinstance(formAreaID, list): printErrorMsg(formAreaID) elif not db_access.get_area_by_id(formAreaID): printErrorMSG(formAreaID) # ------------------------------------| HTML Page start |------------------------------------ else: selectedArea = db_access.get_area_by_id(formAreaID) print(KJM_HTML_Utility.htmlHeader("Selected Area")) print(''' <body> ''') theAreaName = str() theAreaID = 0 for i in selectedArea:
# ------------------------------------| good data received |---------------------------------------------- else: selectedLocation = db_access.get_location_by_id(formLocationID) measurementsForSelectedLocation = db_access.get_measurements_for_location(formLocationID) # ------------------------------------| HTML Page start |------------------------------------ print(KJM_HTML_Utility.htmlHeader("Selected Location")) print(''' <body> ''') for i in selectedLocation: #header identify the area and location by name. locArea = db_access.get_area_by_id(i['location_area']) itsName = str() for aName in locArea: itsName = aName['name'] print("<h1>" + str(i['name']) + "</h1>\n<h2> Area: " + str(itsName) + "</h2>") if measurementsForSelectedLocation: print(u""" <table class="grid"> <thead> <tr> <th>Measurement ID</th> <th>ID</th> <th>Value</th> </tr>