Spaces:
Sleeping
Sleeping
File size: 1,351 Bytes
d252985 7b23660 d252985 |
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 |
import streamlit as st # type: ignore
import pandas as pd # type: ignore
# Initialize notes dataframe
notes_df = pd.DataFrame(columns=['Title', 'Content'])
# Function to add a new note
def add_note(title, content):
new_note = pd.DataFrame({'Title': [title], 'Content': [content]})
global notes_df
notes_df = pd.concat([notes_df, new_note], ignore_index=True)
# Function to update a note
def update_note(index, title, content):
global notes_df
notes_df.at[index, 'Title'] = title
notes_df.at[index, 'Content'] = content
# Function to delete a note
def delete_note(index):
global notes_df
notes_df = notes_df.drop(index)
# Streamlit app
st.title("Note-Taking App")
# Create a new note
st.header("Create a New Note")
title = st.text_input("Title")
content = st.text_area("Content")
if st.button("Add Note"):
add_note(title, content)
# Display all notes
st.header("All Notes")
st.write(notes_df)
# Update a note
st.header("Update a Note")
index = st.selectbox("Select a Note to Update", notes_df.index)
if st.button("Update Note"):
title = st.text_input("New Title")
content = st.text_area("New Content")
update_note(index, title, content)
# Delete a note
st.header("Delete a Note")
index = st.selectbox("Select a Note to Delete", notes_df.index)
if st.button("Delete Note"):
delete_note(index) |