odapi/app/routes.py

21 lines
698 B
Python
Raw Normal View History

2020-04-19 21:30:41 +02:00
from flask import request, jsonify, make_response
from database.crud import insert_data, verify_otp
2020-04-28 20:49:13 +02:00
from app.twilio import send_otp
2020-03-23 21:17:16 +01:00
from app import app
@app.route("/register", methods=["POST"])
def create_user():
2020-03-23 21:17:16 +01:00
data = request.get_json()
insert_data(schema="Users", data=data)
2020-05-03 00:45:45 +02:00
# send_otp(receiver=data["mobile"])
2020-04-19 21:30:41 +02:00
return make_response(jsonify("User created, pending OTP verification"))
@app.route("/verifyotp", methods=["POST"])
def validate_otp():
data = request.get_json()
if verify_otp(mobile=data["mobile"], otp=data["otp"]):
return make_response(jsonify("The OTP has been verified successfully"))
return make_response(jsonify("The OTP is not correct"))