def base(): if request.method == 'OPTIONS': return {} try: params = check.json(request) except: params = [] toret = ret(request.route.rule, params) if not toret.err: err = check.contain(params, ["bearer", "sentence", "token", "lang"]) if not err[0]: toret.add_error(err[1], err[2]) if not toret.err: sent = sentiment(params["token"], params["lang"]) if "analysis" not in params or params["analysis"] == False: err = sent.checktoken(params["token"]) else: err = sent.talk(params["sentence"]) if not err[0]: toret.add_error(err[1], err[2]) else: toret.add_data(err[1]) token = err[1]["user"]["token"].split('_')[0] if not toret.err: df = dialogflowapi(params["bearer"], token, params["lang"]) err = df.talk(params["sentence"]) if not err[0]: toret.add_error(err[1], err[2]) else: toret.data["data"]["response"] = err[1]["response"] return toret.ret()
def base(): try: params = check.json(request) except: params = [] toret = ret(request.route.rule, params) return toret.ret()
def base(): if request.method == 'OPTIONS': return {} try: params = check.json(request) except: params = [] toret = ret(request.route.rule, params) if not toret.err: err = check.contain(params, ["bearer", "exercice"]) if not err[0]: toret.add_error(err[1], err[2]) if not toret.err: df = dialogflowapi(params["bearer"]) err = df.test(params["exercice"]) if not err[0]: toret.add_error(err[1], err[2]) else: toret.add_data(err[1]) return toret.ret()
def base(mail, name): params = {"mail": mail, "name": name} toret = ret(request.route.rule, params) upload = request.files.get('upload') if upload is None: toret.add_error("Missing parameter : upload", 401) if not toret.err: name, ext = os.path.splitext(upload.filename) if ext not in ('.csv'): toret.add_error("Invalid file extension '" + ext + "'", 401) if not toret.err: err = check.contain(params, ["mail", "name"]) if not err[0]: toret.add_error(err[1], err[2]) if not toret.err: exm = exercice_maker(str(uuid.uuid4()), params["mail"], params["name"]) err = exm.csv_to_arr(upload) if not err[0]: toret.add_error(err[1], err[2]) if not toret.err: err = exm.checker(err[1]) if not err[0]: toret.add_error(err[1], err[2]) if not toret.err: err = exm.uploader(err[1]) if not err[0]: toret.add_error(err[1], err[2]) else: toret.add_data(err[1]) return toret.ret()