Question: PYTHON FLASK The Flask application will accept search parameters via a web form and perform basic searches on files local to the webserver. Searches will
PYTHON FLASK
The Flask application will accept search parameters via a web form and perform basic searches on files local to the webserver. Searches will involve JSON objects stored in those files.
I'm trying to create my search function but I keep getting TypeError "string indices must be integers not unicode" and I'm not sure why.
if filename == "2016_Ironhorse_Half": with codecs.open('myp5_4/static/2016_Ironhorse.json') as data_file: data = json.loads(data_file.read())
if filename == "2016_Gobbler_Half": with codecs.open('myp5_4/static/2016_Gobbler.json') as data_file: data = json.loads(data_file.read())
for item in data: if keyToMatch == 'Nothing' | item[keyToMatch] == valueToMatch: #THIS IS THE LINE GETTING THE TYPEERROR if(item[statToFind] != ""): stat = timeToSecond(item[statToFind]) if ((maxOrminVal == null) | maxOrmin == 'MAX' & stat > maxOrminVal | (maxOrmin == 'MIN' & stat < maxOrminVal)): maxOrminVal = stat; searchResult = stuff;
if maxOrminVal == null: ouput = "No results found for the specfified parameters" else: output = 'Search Successful. Required Values are: ' for(key,value) in searchResult.items(): print key + ' = ' + value +' '
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
