Spaces:
No application file
No application file
Update App.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import streamlit as stimport osimport json# App Titlest.title("Notes Maker App")# Sidebarst.sidebar.header("Navigation")options = ["Create Note", "View Notes"]choice = st.sidebar.radio("Select an option:", options)# Directory to store notesNOTES_DIR = "notes"if not os.path.exists(NOTES_DIR):os.makedirs(NOTES_DIR)# Function to save a notedef save_note(title, content):note_path = os.path.join(NOTES_DIR, f"{title}.json")with open(note_path, "w") as file:json.dump({"title": title, "content": content}, file)st.success(f"Note '{title}' saved successfully!")# Function to load notesdef load_notes():notes = []for file_name in os.listdir(NOTES_DIR):with open(os.path.join(NOTES_DIR, file_name), "r") as file:note = json.load(file)notes.append(note)return notes# Main App Logicif choice == "Create Note":st.header("Create a New Note")title = st.text_input("Note Title")content = st.text_area("Note Content")if st.button("Save Note"):if title and content:save_note(title, content)else:st.error("Both title and content are required!")elif choice == "View Notes":st.header("Your Notes")notes = load_notes()if notes:for note in notes:st.subheader(note["title"])st.write(note["content"])else:st.info("No notes found. Create your first note!")
App.py+55