Ankush05 commited on
Commit
d25f219
·
1 Parent(s): ea8d154

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -41
app.py CHANGED
@@ -1,58 +1,64 @@
1
  import streamlit as st
2
- import json
3
- # from streamlit_option_menu import option_menu
4
- # import os
5
- import pandas as pd
6
- # from pymongo.mongo_client import MongoClient
7
- # from dotenv import load_dotenv
8
- # from pymongo.server_api import ServerApi
9
 
10
- # load_dotenv()
 
 
 
11
 
12
- # uri = os.environ["MONGO_CONNECTION_STRING"]
 
 
 
 
13
 
14
- # # Create a new client and connect to the server
15
- # client = MongoClient(uri, ssl=False, server_api=ServerApi('1'), tls=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- # db = client["myapp"]
18
 
19
- # col = db["users"]
 
 
 
 
 
 
 
 
 
20
 
21
- # newuser = {
22
- # "username": "John",
23
- # "password": "sdgsg"
24
- # }
 
25
 
26
- # col.insert_one(newuser)
27
- # print("done!")
28
 
29
- # # Send a ping to confirm a successful connection
30
- # try:
31
- # client.admin.command('ping')
32
- # print("Pinged your deployment. You successfully connected to MongoDB!")
33
- # except Exception as e:
34
- # print(e)
35
 
 
36
 
37
 
38
- # option_menu(None, ["Login", "SignUp"], orientation="horizontal")
39
 
40
 
41
- with open("data.json")as f:
42
- data = json.load(f)
43
 
44
- df = pd.DataFrame(data["reminders"])
45
 
46
- # df =df.drop(columns=["id"])
47
-
48
- # df = df.rename(
49
- # columns={"message":"Message",
50
- # "date":"Date"
51
- # }
52
-
53
- # )
54
-
55
-
56
-
57
- df
58
 
 
 
 
1
  import streamlit as st
2
+ from streamlit_option_menu import option_menu
 
 
 
 
 
 
3
 
4
+ def loadfile():
5
+ with open("data.json") as f:
6
+ data = load.json(f)
7
+ return data
8
 
9
+ def savefile(newuser):
10
+ data = loadfile()
11
+ data['users'].append(newuser)
12
+ with open("data.json", "w") as f:
13
+ json.dump(data, f, indent=4)
14
 
15
+ def signUp():
16
+ username = st.text_input("Username")
17
+ password = st.text_input("Password", type="password")
18
+ confpass = st.text_input("Confirm Password", type="password")
19
+
20
+ newuser = {
21
+ "username": username,"password": Password
22
+ }
23
+ if st.button = "SignUp"
24
+ if password == confpass:
25
+ savedata(newuser)
26
+
27
+ st.write("You are Logged in Sucessfully")
28
+ else:
29
+ st.error("Try again")
30
 
31
+
32
 
33
+ def Login():
34
+ username = st.text_input("username")
35
+ password = st.text_input("Password")
36
+
37
+ if st.button = "Login"
38
+
39
+ if username = "Username" and password = "Password"
40
+ st.sucess("You are logged in")
41
+ else:
42
+ st.error("Your username or password do not match")
43
 
44
+ def main():
45
+ with st.sidebar:
46
+ selected = option_menu("Menu", ["Login", "Signup"], icons = ["house", "person"])
47
+ if selected == "Login":
48
+ Login()
49
 
50
+ if selected == "Signup":
51
+ SignUp()
52
 
53
+ main()
 
 
 
 
 
54
 
55
+
56
 
57
 
 
58
 
59
 
 
 
60
 
 
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
+
64
+