Spaces:
Sleeping
Sleeping
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) |