forked from SANTHAN-KUMAR/Answer-sheet-processor
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
52 lines (43 loc) · 1.89 KB
/
Copy pathapp.py
File metadata and controls
52 lines (43 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# app.py
import streamlit as st
from auth import signup, login, verify_otp
st.set_page_config(page_title="Smart Answer Sheet Scanner", layout="wide")
def main():
if "authenticated_user" not in st.session_state:
st.title("🔐 Welcome to Smart Scanner")
tab = st.radio("Choose Action", ["Sign In", "Sign Up"], horizontal=True)
if tab == "Sign Up":
username = st.text_input("Username")
email = st.text_input("Email")
password = st.text_input("Password", type="password")
if st.button("Send OTP"):
msg = signup(username, email, password)
st.info(msg)
if "temp_signup" in st.session_state:
entered_otp = st.text_input("Enter OTP to verify")
if st.button("Verify OTP"):
result = verify_otp(entered_otp)
st.success(result)
if result.startswith("Account created"):
st.session_state.authenticated_user = username
st.rerun()
elif tab == "Sign In":
email = st.text_input("Email")
password = st.text_input("Password", type="password")
if st.button("Login"):
user = login(email, password)
if user:
st.success("Login successful!")
st.session_state.authenticated_user = user["username"]
st.rerun()
else:
st.error("Invalid credentials.")
st.stop()
# 🔓 Authenticated user
st.sidebar.success(f"Logged in as: {st.session_state.authenticated_user}")
st.sidebar.button("Logout", on_click=lambda: st.session_state.pop("authenticated_user"))
# 🔁 Now load your main app
from answer_sheet_streamlit import main as scanner_main
scanner_main()
if __name__ == "__main__":
main()