-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
51 lines (43 loc) · 1.78 KB
/
app.py
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
import streamlit as st
from database_access import *
from student import student
from teacher import teacher
from dashboard import dashboard
authentication_status = False
def render_page(username, state):
match state:
case "Student":
student(username)
case "Teacher":
teacher(username)
case "Admin":
dashboard()
def set_null():
for i in st.session_state:
del st.session_state[i]
def main():
st.title("Attendance Mapping System")
choice = st.sidebar.selectbox("Menu", ["Home", "Login"])
match choice:
case "Home":
st.subheader("View and Manage your attendance records")
st.image("./attendance.jpg", width = 200)
case "Login":
username = st.sidebar.text_input("Username")
password = st.sidebar.text_input("Password", type = "password")
state = st.sidebar.radio("Login As", ["Student", "Teacher", "Admin"], key = "state")
if (('Logged In' in st.session_state.keys()) and (state == st.session_state['prev_state'])):
if st.sidebar.button("Logout"):
set_null()
st.experimental_rerun()
render_page(username, state)
else:
if st.sidebar.button("Login"):
if authenticate_login(username, password, state):
st.session_state["Logged In"] = True
st.session_state["prev_state"] = state
render_page(username, state)
else:
st.error("Incorrect Username or Password Combination")
if __name__ == '__main__':
main()