def div_handler(): if request.method == "OPTIONS": return json.dumps({'status': True}) status = False result = None data = request.json if data is not None: if data['number1'] is not None and \ data['number2'] is not None: calc = Calc() result = calc.div(data['number1'], data['number2']) status = True response.headers['Content-Type'] = 'application/json' return json.dumps({'status': status, 'result': result})
def add_handler(): if request.method == "OPTIONS": return json.dumps({'status': True}) status = False result = None data = request.json print("data:", data) if data is not None: if data['number1'] is not None and \ data['number2'] is not None: calc = Calc() result = calc.add(data['number1'], data['number2']) #sql_insert_query = "insert into `personaje` values(NULL, '%s', '%s', '%s')" % (data['first_name'], data["last_name"], data["twitter"]) #result = cursor.execute(sql_insert_query) #cnx.commit() status = True response.headers['Content-Type'] = 'application/json' return json.dumps({'status': status, 'result': result})