- I have a method in this I am extracting email id and mobile number from the database.
- I am using POSTGRES as database and using python language.I need to pass the value to the second method for the OTP purpose but I am running into an error.
JavaScript
x
18
18
1
@app.route("/", methods=['GET', 'POST'])
2
def userlogin():
3
sql_mobile_query = """SELECT users.phone FROM users WHERE users.email = %s"""
4
cursor.execute(sql_mobile_query, record_to_search)
5
mobile = cursor.fetchone()
6
mobile_new = mobile[0]
7
sql_email_query = """SELECT users.email FROM users WHERE users.email = %s"""
8
cursor.execute(sql_email_query, record_to_search)
9
email = cursor.fetchone()
10
email_new = email[0]
11
connection.commit()
12
if(role == ('Admin',) and eotp == ('False',) and motp == ('False')):
13
return "No need of OTP"
14
else:
15
return redirect(url_for('otp', email=email_new , mobile=mobile_new))
16
connection.commit()
17
print("Logged in sucessfully")
18
- I have another method I need to access the email id and mobile number in this method that is passed from the above
userlogin()
method
JavaScript
1
7
1
@app.route("/otp/<email>/<mobile>", methods=['GET', 'POST'])
2
def otp(email, mobile):
3
email = email
4
mobile = mobile
5
print(email, mobile)
6
return render_template("otp_screen.html")
7
Advertisement
Answer
Solved. I just don’t have to assign new variable in this method @app.route("/otp/<email>/<mobile>", methods=['GET', 'POST'])