def get_iss_info_by_input(req): """ GET current iss information: Location, Passing by given coordinates, or People aboard from command-line input """ user_request = utils.process_request(req) print(user_request)
def upvote(): try: df = utils.read_data(FILE) if len(request.form["search_type"]) > 0 and isinstance(request.form["search_type"], str) == True and str(request.form["search_type"]) in ["label_choice", "name_choice", "research_choice"]: search_type = request.form["search_type"] if search_type == "label_choice": send_msg = request.form["wine_name"] answer = str(send_msg) elif search_type == "name_choice": answer = df.loc[df['name'] == str(request.form["wine_name"])] answer = answer[['name', 'image', 'pays','region', 'appelation', 'domaine', 'millesime', 'couleur','description']].head(10) elif search_type == "research_choice": couleur = str(request.form["couleur"]) pays = str(request.form["pays"]) want = str(request.form["want"]) want = utils.remove_stop_words(want, STOP) want = str(utils.process_request(want)) answer = utils.generate_research_choice(df, couleur, pays) if len(want) > 0: answer = utils.treat_input(answer,want,'clean_text') else: pass else: pass return utils.generate_answer(answer) else: return False except: return False
def post(self, request, format=None): try: utils.validate_request_data(request) except ValueError as e: response_data = dict() # standard format to be followed for custom exceptions response_data[ 'message'] = "Exception : " + e.__class__.__name__ + " :- " + e.__str__( ) utils.LOGGER.error("Validation during validation: " + response_data['message']) return Response(response_data, status=status.HTTP_400_BAD_REQUEST) finally: pass # process the request as per action value passed in body return utils.process_request(request)
def predict_api(): try: model = pd.read_pickle(os.path.join(fix_path(), "models/model.pkl")) logging.info("RFregressor version: ", pkg_resources.get_distribution("scikit-learn")) # observation = observation.encode() # this code is for scenario where data is encoded as str in POST # observation = pickle.loads(base64.b64decode(observation)) # request = open('request.json', 'rb') # todo - comment out if not testing locally observation = request.json observation = process_request(observation=observation) pred = model.get_prediction(observation) return jsonify({"bitcoin prediction": str(pred)}) except Exception as ex: logging.error("No model was found, so run /train")
def decrypt(): return process_request(request, "decrypt")
def initialise(): return process_request(request, "initialise")
try: if jdata['channel'] == 'twilio': print("Channel = Twilio") result = twilio_password_reset(data) print("sleeping for 20 seconds") time.sleep(20) print("sending email") send_email(result) asid = jdata['asid'] csid = jdata['csid'] url = jdata['redirect_url_success'] print("routing call") twilio_route_call(asid, csid, url) else: result = process_request(data) print(result) scData = dict(cData) scData['hangUp'] = True bot_data = { 'text': 'Your password has been reset and an email will be sent to your manager containingg the new password.', 'channelData': { 'hangUp': True }, 'address': jdata['address'] } send_to_queue(bot_data, 'send-to-bot') send_email(result)