itachi1234 commited on
Commit
2a7939e
·
verified ·
1 Parent(s): 33499ae

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -92
app.py DELETED
@@ -1,92 +0,0 @@
1
- import streamlit as st
2
- from home import dashboard
3
- from streamlit_option_menu import option_menu
4
- import json
5
- import uuid
6
-
7
-
8
- st.set_page_config(page_title="Authentication", page_icon=":guardsman:", layout="wide")
9
-
10
- # st.title("Authentication")
11
-
12
-
13
- def load_json():
14
- with open("database/data.json") as file:
15
- data = json.load(file)
16
- return data
17
-
18
-
19
-
20
-
21
-
22
- def save_json():
23
- with open("database/data.json", "w") as file:
24
- json.dump( file, indent=4)
25
-
26
-
27
-
28
- def login():
29
- st.title("Login")
30
- data = json.load(open("database/data.json"))
31
- usrname = st.text_input("Username")
32
- password = st.text_input("Password", type="password")
33
- if st.button("Login", key="loginkey"):
34
- for user in data["users"]:
35
-
36
- st.session_state["user"] = "logged"
37
- flag = True
38
- st.experimental_rerun()
39
-
40
- st.balloons()
41
-
42
-
43
- def signup():
44
-
45
- st.title("Signup")
46
- username = st.text_input("Username")
47
- password = st.text_input("Password", type="password")
48
- confirm_password = st.text_input("Confirm Password", type="password")
49
- if st.button("Signup", key="signupkey"):
50
- if password == confirm_password:
51
- data = json.load(open("database/data.json"))
52
- newuser = {
53
- "username": username,
54
- "password": password,
55
- "id": str(uuid.uuid4())
56
- }
57
- data["users"].append(newuser)
58
- json.dump(data, open("database/data.json", "w"), indent=4)
59
- st.success("Account created! You can now login.")
60
- st.snow()
61
- st.cache_data.clear()
62
- else:
63
- st.error("Passwords do not match")
64
-
65
- def main():
66
- # st.title("Authentication")
67
- if "user" not in st.session_state:
68
- st.session_state["user"] = "visitor"
69
-
70
-
71
-
72
- if st.session_state["user"] == "logged":
73
- dashboard()
74
-
75
- elif st.session_state["user"] == "visitor":
76
-
77
- option = option_menu(
78
- menu_title="Authentication",
79
- options=["Login", "Signup"],
80
- icons=["house", "activity"],
81
- menu_icon="cast",
82
- default_index=0,
83
- orientation="horizontal",
84
-
85
- )
86
- if option == "Login":
87
- login()
88
- elif option == "Signup":
89
- signup()
90
-
91
-
92
- main()