-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
63 lines (52 loc) · 1.69 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
52
53
54
55
56
57
58
59
60
61
62
63
import ui.login
import ui.dashboard
import api.moodle
import streamlit
import os
from mongoengine import *
from dotenv import load_dotenv
load_dotenv()
connect(
os.getenv("MONGO_DATABASE"),
username=os.getenv("MONGO_USER"),
password=os.getenv("MONGO_PASS"),
authentication_source="admin",
host=os.getenv("MONGO_HOST"),
port=27017,
)
WCE_LOGO_PATH = os.getenv("WCE_LOGO_PATH")
streamlit.set_page_config(
page_title="WCE Project Management",
page_icon=WCE_LOGO_PATH,
layout="wide",
initial_sidebar_state="expanded",
)
hide_menu_style = """
<style>
#MainMenu {visibility: hidden;}
</style>
"""
streamlit.markdown(hide_menu_style, unsafe_allow_html=True)
if "token" not in streamlit.session_state:
streamlit.session_state.token = ""
streamlit.session_state.verified = False
streamlit.session_state.data = {}
streamlit.session_state.admin = False
if not api.moodle.isValid(streamlit.session_state.token):
streamlit.session_state.data = ui.login.login()
if streamlit.session_state.admin:
streamlit.session_state.token = ""
streamlit.session_state.verified = True
else:
try:
streamlit.session_state.token = streamlit.session_state.data["token"]
streamlit.session_state.verified = True
except Exception as e:
streamlit.session_state.token = ""
streamlit.session_state.verified = False
if streamlit.session_state.verified == True:
streamlit.experimental_rerun()
else:
ui.dashboard.dashboard()
if streamlit.session_state.verified == False:
streamlit.experimental_rerun()