I have a function through which I am trying to return a series of houses, filtered by a price.
Here is the function:
@app.route('/calcprice', methods=['GET', 'POST'])
def calcprice():
price = '120000'
if request.method == 'POST':
testVal = request.form
price = str(testVal['Income'])
# The view function did not return a valid response
res = [d for d in output_dict if d['ListPrice']<=float(price)]
# gets an unhashable type
it = iter(res)
res_dct = dict(zip(it, it))
# The tuple must have the form (body, status, headers), (body, status), or (body, headers).
res_tpl = tuple(res)
return res
When I go with "res", I get the commented error. When I go with "res_dct" as the response, I get that commented error. Same with the tuple and its commented response. I am changing the return to return the correct given variable.
res itself is a list of dictionaries, here is a snapshot:
{'MLSNumber': '9504716', 'ListPrice': '659849.00', 'BedsTotal': '4', 'MLSAreaMinor': 'Greenways At Sand Creek', 'StreetNumber': '3819', 'StreetName': 'Ivy Hill', 'PostalCode': '80922', 'TaxAmount': '200.00'}, {'MLSNumber': '4426383', 'ListPrice': '1500000.00', 'BedsTotal': '4', 'MLSAreaMinor': 'Keene Ranch', 'StreetNumber': '3231', 'StreetName': 'Castle Butte', 'PostalCode': '80109', 'TaxAmount': '4967.00'}
Here, too, is the div I am ultimately injecting the information into:
<div class="row">
{% for item in purchase %}
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title"> MLS: {{ item['MLSNumber'] }}</h5>
<p class="card-text">List Price: {{ item['ListPrice'] }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
It works with the first list until I update the variable price via an input field. Then the error about the valid response kicks in.
Where(s) am I going wrong?