marbleoo commited on
Commit
f7778ed
1 Parent(s): e73e2a2

First Submission of my todolist work

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pymongo
3
+
4
+ uri = "mongodb+srv://123123:mb123123@cluster.c0bshep.mongodb.net/?retryWrites=true&w=majority"
5
+
6
+ client = pymongo.MongoClient(uri)
7
+ db = client["demo"]
8
+ collection = db["class"]
9
+
10
+ st.title('TODO LIST')
11
+ st.write('This is a TODO List which allows you to insert, update, delete your task')
12
+
13
+ page = st.sidebar.selectbox('Menu', ['Home', 'Insert', 'Edit', 'Delete'])
14
+
15
+ if page == 'Insert':
16
+ st.header('Insert Task')
17
+ task = st.text_input('Task')
18
+ cate = st.selectbox('Category', ['Work', 'Study', 'Entertainment'])
19
+
20
+ if st.button('Insert'):
21
+ collection.insert_one({'Task':task, 'Category': cate})
22
+ st.success('Successfully Inserted')
23
+
24
+ elif page == 'Edit':
25
+ st.header('Edit Task')
26
+
27
+ elif page == 'Delete':
28
+ st.header('Delete Task')
29
+ task = st.text_input('Input the Task&Category you want to delete')
30
+ cate = st.selectbox('Category', ['Work', 'Study', 'Entertainment'])
31
+
32
+ if st.button('Delete'):
33
+ collection.delete_one({'Task':task, 'Category':cate})
34
+ st.success('Successfully Deleted')
35
+
36
+ elif page == 'Home':
37
+ st.header('Home Page')
38
+ tasks = collection.find({}, {'_id':0, })
39
+ st.table(tasks)