Posted too soon -- I initially saw errors for a problem that I'd fixed locally, but thought that the top was most recent. I pulled my most recent changes from github, and now I'm seeing an error that I'm not sure how to address, because it's working properly locally:
2013-10-02 14:14:45,138 :Exception on /search_results/DCY [GET]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/kaburgett/flask-platespotting/spot/views.py", line 31, in search_results
IndexError: list index out of range
And here's my views.py route for that url path:
@plate.route('/search_results/<query>')
def search_results(query):
plate_type = ''
flag_image = ''
plate_type_options = {'D': 'Diplomat', 'C': 'Foreign Consul', 'S': 'Non-diplomatic Staff'}
plate_type_index = query[0].upper()
if plate_type_index in plate_type_options:
plate_type = plate_type_options[plate_type_index]
country = query[1:3]
results = Code.query.whoosh_search(country).all()
if results:
flag_image = results[0].country.country_name.replace(' ', '-')
return render_template('country_page.html',
query = query,
results = results,
plate_type = plate_type,
flag_image = flag_image)