-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.py
56 lines (40 loc) · 1.36 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
import streamlit as st
import psycopg2
from config import Config
from login import login_main
from SellerGUI import SellerMain
from BuyerGUI import BuyerMain
from CarCheckerGUI import CarCheckerMain
from MechanicGUI import MechanicMain
db_params = {
"host": Config.HOST,
"database": Config.DATABASE,
"user": Config.USER,
"password": Config.PASSWORD
}
connection = psycopg2.connect(**db_params)
cursor = connection.cursor()
st.title("Funny Car Shop")
def main():
if "authenticated" not in st.session_state:
st.session_state["authenticated"] = False
if "username" not in st.session_state:
st.session_state["username"] = None
if st.session_state['authenticated'] == False and st.session_state["username"] is None:
login_main()
else:
user_id = st.session_state["user_id"]
cursor.execute(f'SELECT * FROM account WHERE AID = {str(st.session_state["user_id"])};')
user_info = cursor.fetchone()
# user info
user_type = user_info[4]
if (user_type == "Seller"):
SellerMain()
elif(user_type == "Buyer"):
BuyerMain()
elif (user_type == "CarChecker"):
CarCheckerMain()
elif (user_type == "Mechanic"):
MechanicMain()
if __name__ == "__main__":
main()