def search(): logger = Logger() dao = DAO() try: search_value = str(request.form["search_value"]).strip() all_results = [] if len(search_value.strip()) == 5 and search_value.isdigit(): # logger.log("Searching %s" % search_value) by_zip = dao.by_zip(search_value) # logger.log(str(by_zip)) all_results.extend(by_zip) else: by_name = dao.by_name(search_value) all_results.extend(by_name) return jsonify(all_results) except Exception as e: return logger.filename + " " + str(e)
def admin_search(): try: search_value = str(request.form.get("search_value", None)) if search_value and search_value.strip(): search_value = search_value.strip() dao = DAO() results = dao.by_name(search_value) final_results = [] for result in results: title = result["title"] if is_last_name(search_value, title): # if not title_exists(final_results, title): final_results.append(result) final_results = format_surgeons(final_results) return jsonify(list(final_results)) except Exception as e: print(str(e)) return jsonify({"Error": "Something went wrong"})