Sending an email consisting of a verification code and verify that e-mail with a countdown clock in streamlit

I would like to send an email verification code for a user that provide an email to website and verify that email in a limited time period. I can send email with a function but cant verify it with current functions in streamlit.

I tried the script below but it stops after printing β€œt”.

email_form = st.form(key='my_email_form',clear_on_submit=False)
email=email_form.text_input(label='Please enter your email address')
submit_e_button = email_form.form_submit_button(label='Send')

if submit_e_button:
    with st.form(key='my_code'):
        code = st.text_input(label='Enter code')
        submit_button = st.form_submit_button(label='Confirm')
    global t1
    t1=time.time()
    fixed_digits = 4
    key=random.randrange(1111, 9999, fixed_digits)
    sentmail2()
    t=0
    async def clocktime():
        global t
        ph = st.empty()
        N = 1*60
        for secs in range(N,0,-1):
            mm, ss = secs//60, secs%60
            ph.metric("Countdown", f"{mm:02d}:{ss:02d}")
            time.sleep(1)
            t2=time.time()
            t=t2-t1
            if ss==1:
              ph.metric("Countdown", "Time is out")
    async def submittion():
        print(t)
        if submit_button:
            if float(t) > 1*60:
                st.text('Enter before the time limit.')
                b = False
          # print("You have run out of time!")
            if float(t) < 1*60: 
                print("code " + str(code))
                print(key)
                if submit_button:
                    if b == True:
                      print("code" + code)
                      print(key)
                      if str(code)==str(key):
                        st.text('succcess')
        
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    asyncio.ensure_future(clocktime())
    asyncio.ensure_future(submittion())
    loop.run_forever()

Thanks.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.