File size: 1,529 Bytes
33a2172
541f4f3
36e58bc
541f4f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36e58bc
26d4526
541f4f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import json
from pages.home import page

st.set_page_config(page_title="Reminder App", page_icon=":bell:", layout="centered")

login, signup = st.tabs(["Login", "Signup"])


@st.cache_data
def loadFile():
    with open("database/test.json") as json_file:
       return  json.load(json_file)
        
    
def saveFile(data):
    with open("database/test.json", "w") as file:
        json.dump(data, file, indent=4)

def LoginPage():
    st.title("Login")
    username = st.text_input("Username", key="username")
    password = st.text_input("Password", type="password", key="password")
    if st.button("Login"):
        data = loadFile()
        for user in data["users"]:
            if username == user["username"] and password == user["password"]:
                st.success("Logged in as {}".format(username))
                st.balloons() 
                home.page()
            else:
                st.error("Incorrect username or password")
            
def SignupPage():
    st.title("Signup")
    username = st.text_input("Username", key="svusername")
    email = st.text_input("Email", key="svemail")
    password = st.text_input("Password", type="password", key="svpassword")
    if st.button("Signup"):
        data = loadFile()
        data["users"].append({"username": username, "password": password, "email": email})
        saveFile(data)
        st.success("Successfully signed up as {}".format(username))
            
with login:
    LoginPage()
    
with signup:
    SignupPage()