CosmoAI commited on
Commit
541f4f3
·
1 Parent(s): 9b32d1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -39
app.py CHANGED
@@ -1,40 +1,51 @@
1
  import streamlit as st
2
- import pandas as pd
3
-
4
- def main():
5
- # Create a title for the dashboard
6
- st.title("Dashboard")
7
-
8
- # Create a sidebar with a dropdown menu
9
- with st.sidebar:
10
- options = ["Profile", "Statistics", "About"]
11
- option = st.selectbox("Select an option", options)
12
-
13
- # Display the profile information if the user selects "Profile"
14
- if option == "Profile":
15
- profile = pd.DataFrame({
16
- "Name": ["Hennifer Doe"],
17
- "Email": ["hennifer.[email protected]"],
18
- "Location": ["San Francisco, CA"],
19
- })
20
- st.dataframe(profile)
21
-
22
- # Display the statistics if the user selects "Statistics"
23
- elif option == "Statistics":
24
- statistics = pd.DataFrame({
25
- "Number of Visitors": 1000,
26
- "Average Time Spent on Page": 2,
27
- "Bounce Rate": 10,
28
- })
29
- st.dataframe(statistics)
30
-
31
- # Display the about information if the user selects "About"
32
- else:
33
- about = """
34
- This is a simple dashboard created with Streamlit.
35
- You can select an option from the sidebar to display different information.
36
- """
37
- st.write(about)
38
-
39
- if __name__ == "__main__":
40
- main()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import json
3
+
4
+ st.set_page_config(page_title="Reminder App", page_icon=":bell:", layout="centered")
5
+
6
+ login, signup = st.tabs(["Login", "Signup"])
7
+
8
+
9
+ @st.cache_data
10
+ def loadFile():
11
+ with open("database/test.json") as json_file:
12
+ return json.load(json_file)
13
+
14
+
15
+ def saveFile(data):
16
+ with open("database/test.json", "w") as file:
17
+ json.dump(data, file, indent=4)
18
+
19
+ def LoginPage():
20
+ st.title("Login")
21
+ username = st.text_input("Username", key="username")
22
+ password = st.text_input("Password", type="password", key="password")
23
+ if st.button("Login"):
24
+ data = loadFile()
25
+ for user in data["users"]:
26
+ if username == user["username"] and password == user["password"]:
27
+ st.success("Logged in as {}".format(username))
28
+ st.balloons()
29
+ else:
30
+ st.error("Incorrect username or password")
31
+
32
+ def SignupPage():
33
+ st.title("Signup")
34
+ username = st.text_input("Username", key="svusername")
35
+ email = st.text_input("Email", key="svemail")
36
+ password = st.text_input("Password", type="password", key="svpassword")
37
+ if st.button("Signup"):
38
+ data = loadFile()
39
+ data["users"].append({"username": username, "password": password, "email": email})
40
+ saveFile(data)
41
+ st.success("Successfully signed up as {}".format(username))
42
+
43
+ with login:
44
+ LoginPage()
45
+
46
+ with signup:
47
+ SignupPage()
48
+
49
+
50
+
51
+