#####################################################################################
# Web Page access functions
# retrieve user input, send output to screen 
#####################################################################################
import cgi
import cgitb
cgitb.enable()
import config

#====================================================================================
# input(): get user input from the web form
#  return: dictionary of input elements
#====================================================================================
def input():

    input = {}
    elements   = cgi.FieldStorage()     #obtain all http parameter names/values
    fieldnames = elements.keys()        #get all the form field names
    for name in fieldnames:
        input[name] = elements.getvalue(name)

    if isinstance(input.get('srch'), list):                         #Python bug? returning a list instead of a single value 
        input['srch'] = input['srch'][0]  
 
    if config.RUN_MODE=='test': print('INPUT=>',input,'<br>')       #for debugging
    return input

#====================================================================================
# main - used for testing only - all commented out
#====================================================================================
"""
input = input()
print(input)

"""