mrciomnl commited on
Commit
d252985
·
1 Parent(s): 5a730bc

added necessary code

Browse files
Files changed (2) hide show
  1. app.py +50 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st # type: ignore
2
+ import pandas as pd # type: ignore
3
+
4
+ # Initialize notes dataframe
5
+ notes_df = pd.DataFrame(columns=['Title', 'Content'])
6
+
7
+ # Function to add a new note
8
+ def add_note(title, content):
9
+ new_note = pd.DataFrame({'Title': [title], 'Content': [content]})
10
+ global notes_df
11
+ notes_df = pd.concat([notes_df, new_note], ignore_index=True)
12
+
13
+ # Function to update a note
14
+ def update_note(index, title, content):
15
+ global notes_df
16
+ notes_df.at[index, 'Title'] = title
17
+ notes_df.at[index, 'Content'] = content
18
+
19
+ # Function to delete a note
20
+ def delete_note(index):
21
+ global notes_df
22
+ notes_df = notes_df.drop(index)
23
+
24
+ # Streamlit app
25
+ st.title("Note-Taking Application")
26
+
27
+ # Create a new note
28
+ st.header("Create a New Note")
29
+ title = st.text_input("Title")
30
+ content = st.text_area("Content")
31
+ if st.button("Add Note"):
32
+ add_note(title, content)
33
+
34
+ # Display all notes
35
+ st.header("All Notes")
36
+ st.write(notes_df)
37
+
38
+ # Update a note
39
+ st.header("Update a Note")
40
+ index = st.selectbox("Select a Note to Update", notes_df.index)
41
+ if st.button("Update Note"):
42
+ title = st.text_input("New Title")
43
+ content = st.text_area("New Content")
44
+ update_note(index, title, content)
45
+
46
+ # Delete a note
47
+ st.header("Delete a Note")
48
+ index = st.selectbox("Select a Note to Delete", notes_df.index)
49
+ if st.button("Delete Note"):
50
+ delete_note(index)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit