Spaces:
Sleeping
Sleeping
File size: 1,201 Bytes
f7778ed |
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 |
import streamlit as st
import pymongo
uri = "mongodb+srv://123123:mb123123@cluster.c0bshep.mongodb.net/?retryWrites=true&w=majority"
client = pymongo.MongoClient(uri)
db = client["demo"]
collection = db["class"]
st.title('TODO LIST')
st.write('This is a TODO List which allows you to insert, update, delete your task')
page = st.sidebar.selectbox('Menu', ['Home', 'Insert', 'Edit', 'Delete'])
if page == 'Insert':
st.header('Insert Task')
task = st.text_input('Task')
cate = st.selectbox('Category', ['Work', 'Study', 'Entertainment'])
if st.button('Insert'):
collection.insert_one({'Task':task, 'Category': cate})
st.success('Successfully Inserted')
elif page == 'Edit':
st.header('Edit Task')
elif page == 'Delete':
st.header('Delete Task')
task = st.text_input('Input the Task&Category you want to delete')
cate = st.selectbox('Category', ['Work', 'Study', 'Entertainment'])
if st.button('Delete'):
collection.delete_one({'Task':task, 'Category':cate})
st.success('Successfully Deleted')
elif page == 'Home':
st.header('Home Page')
tasks = collection.find({}, {'_id':0, })
st.table(tasks) |