Module_2 / login.py
srbhavya01's picture
Update login.py
75f9a29 verified
raw
history blame
770 Bytes
import streamlit as st
import random
from database import create_table, add_user
create_table()
st.title("💪 FitPlan AI Login")
email = st.text_input("Enter Email")
if "otp" not in st.session_state:
st.session_state.otp = None
# Generate OTP
if st.button("Send OTP"):
if email:
otp = random.randint(100000,999999)
st.session_state.otp = otp
st.success(f"Your OTP is: {otp}")
# Save user in database
add_user(email)
else:
st.warning("Enter email first")
user_otp = st.text_input("Enter OTP")
if st.button("Verify OTP"):
if str(st.session_state.otp) == user_otp:
st.session_state.logged_in = True
st.success("Login Successful 🎉")
else:
st.error("Invalid OTP")