def search(): form = SearchForm.from_json(request.get_json(), csrf_enabled=False) if form.validate(): # Get state and county from location location = get_state_and_county(form.location.data) # If answer is not a dict with results, return error message. if type(location) != dict: return location, 400 # Return 400 something error if caused user # If cause by me the 500 something # Turn date object into string date = str(form.date.data) county = location['county'].lower() state = location['state'].lower() # Get cases and deaths for selected dates covid_data = get_covid_data(date, state, county) if type(covid_data) != dict: return covid_data, 400 return jsonify(covid_data) return 'Bad request', 400 """ Show search or search result """