def calculate_estimated_price(): try: json_request = request.json zip_code = json_request['zipcode'] area = json_request['area'] estimated_rent, latest_date = algorithm.get_estimated_rent(zip_code, area) json_resp = json.dumps({'area': area, 'zipcode': zip_code, 'estimated_rent': estimated_rent, 'latest_date': latest_date}) resp = Response(json_resp, status=200, mimetype='application/json') return resp except Exception, e: logger.debug(str(e)) return Response(json.dumps({'error': str(e)}), status=500, mimetype='application/json')
latest_date = '' positive_words = [] negative_words = [] duplicated_image = [] duplicated_address = [] try: # ADDRESS address = json_listing['address'] if address is None or address['zipcode'] is None: # No address, increase the score score += 2 else: # RENT PRICE estimated_rent, latest_date = algorithm.get_estimated_rent( address['zipcode'], json_listing['area']) score += algorithm.check_price(estimated_rent, json_listing['price']) # DUPLICATE IMAGES image_score, duplicated_image = algorithm.check_images( json_listing['image'], address['lat'], address['lon'], json_listing['price']) score += image_score # DUPLICATE ADDRESS address_score = 0 try: address_score, duplicated_address = algorithm.check_address( address['state'], address['city'], address['street'], json_listing['price'])